Skip to contents

This function creates a logger object that can be used with logtext() to write console output to a log file on disk.

Usage

get_logger(
  dir = getwd(),
  fname = NULL,
  add_git_info = TRUE,
  git_dir = NULL,
  init_log_file = TRUE
)

Arguments

dir

path to directory where to log output (default is current directory)

fname

log file name (default is current system date and time)

add_git_info

(logical) whether to add current git commit info to logger and file name (default TRUE)

git_dir

path to git repository (if different from dir)

init_log_file

(logical) whether to log an initial message (by printing the logger to the text file; default is TRUE)

Value

logger object (list) with elements:

fname

log file name

dir

log directory

gitcommit

(optional) list with elements HEAD, SHA, and COMMIT_MSG; see get_git_commit()

Examples

if (FALSE) {
logger <- get_logger()
logger |> logtext(expr=print("hello world!"))
}