Skip to contents

Function for writing a log file from R containing three rows and three columns. The log file can report the current status of maximal three processes. The first row describes the top process. The second row describes the status of the process within the top process. The third row can be used to describe the status of a process within the middle process.

The log can be read with read_log.

Usage

write_log(
  log_file,
  value_top = 0,
  total_top = 1,
  message_top = NA,
  value_middle = 0,
  total_middle = 1,
  message_middle = NA,
  value_bottom = 0,
  total_bottom = 1,
  message_bottom = NA,
  last_log = NULL,
  write_interval = 2
)

Arguments

log_file

string Path to the file where the log should be saved and updated.

value_top

double Current value for the top process.

total_top

double Maximal value for the top process.

message_top

string Message describing the current state of the top process.

value_middle

double Current value for the middle process.

total_middle

double Maximal value for the middle process.

message_middle

string Message describing the current state of the middle process.

value_bottom

double Current value for the bottom process.

total_bottom

double Maximal value for the bottom process.

message_bottom

string Message describing the current state of the bottom process.

last_log

POSIXct Time when the last log was created. If there is no log file set this value to NULL.

write_interval

int Time in seconds. This time must be past before a new log is created.

Value

This function writes a log file to the given location. If log_file is NULL the function will not try to write a log file.

If log_file is a valid path to a file the function will write a log if the time specified by write_interval has passed. In addition the function will return an object of class POSIXct describing the time when the log file was successfully updated. If the initial attempt for writing log fails the function returns the value of last_log which is NULL by default.