rotate_logs: Rotate log file

Description Usage Arguments Details Examples

View source: R/utils.R

Description

Truncates the log file to the line count provided as rotate_lines.

Usage

1
rotate_logs(rotate_lines = 1e+05, logfile)

Arguments

rotate_lines

The number of log entries to keep in the logfile. Defaults to 100,000.

logfile

Log file to truncate. Defaults to the currently-configured log file.

Details

loggit makes no assumptions nor enforcement of calling this function; that is to say, the onus of log rotation is up to the developer. You

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
  # Truncate "default" log file to 100 lines
  set_logfile()
  for (i in 1:150) {loggit("INFO", i, echo = FALSE)}
  rotate_logs(100)
  
  # Truncate a different log file to 250 lines
  another_log <- file.path(tempdir(), "another.log")
  set_logfile(another_log)
  for (i in 1:300) {loggit("INFO", i, echo = FALSE)}
  set_logfile() # clears pointer to other log file
  rotate_logs(250, another_log)

loggit documentation built on Feb. 28, 2021, 9:06 a.m.