log_read {autometric}R Documentation

Read a log.

Description

Read a log file into R.

Usage

log_read(
  path,
  units_cpu = c("percentage", "fraction"),
  units_memory = c("megabytes", "bytes", "kilobytes", "gigabytes"),
  units_time = c("seconds", "minutes", "hours", "days"),
  hidden = FALSE
)

Arguments

path

Character vector of paths to files and/or directories of logs to read.

units_cpu

Character string with the units of the cpu field. Defaults to "percentage" and must be in c("percentage", "fraction").

units_memory

Character string with the units of the memory field. Defaults to "megabytes" and must be in c("megabytes", "bytes", "kilobytes", "gigabytes").

units_time

Character string, units of the time field. Defaults to "seconds" and must be in c("seconds", "minutes", "hours", "days").

hidden

TRUE to include hidden files in the files and directories listed in path, FALSE to omit.

Details

log_read() is capable of reading a log file where both autometric and other processes have printed. Whenever autometric writes to a log, it bounds the beginning and end of the text with the keyword "__AUTOMETRIC__". that way, log_read() knows to only read and process the correct lines of the file.

In addition, it automatically converts the log data into the units units_time, units_cpu, and units_memory arguments.

Value

A data frame of metrics from the log with one row per log entry and columns with metadata and resource usage metrics. log_read() automatically converts the data into the units chosen with arguments units_time, units_cpu, and units_memory. The returned data frame has the following columns:

Examples

  path <- tempfile()
  log_start(seconds = 0.5, path = path)
  Sys.sleep(2)
  log_stop()
  Sys.sleep(2)
  log_read(path)
  unlink(path)

[Package autometric version 0.1.2 Index]