Learn R Programming

vcr (version 1.6.0)

vcr_logging: vcr log file setup

Description

vcr log file setup

Usage

vcr_log_file(file, overwrite = TRUE)

vcr_log_info(message, include_date = TRUE)

Arguments

file

(character) a file path, required

overwrite

(logical) whether or not to overwrite the file at 'file' if it already exists. Default: TRUE

message

(character) a message to log

include_date

(logical) include date and time in each log entry. Default: FALSE

Examples

Run this code
# user workflow
vcr_configuration()
logfile <- file.path(tempdir(), "vcr.log")
vcr_configure(dir = tempdir(), log = TRUE, log_opts = list(file = logfile))

readLines(logfile) # empty

# log messages
vcr_log_info("hello world!")
readLines(logfile)
vcr_log_info("foo bar")
readLines(logfile)
## many messages
vcr_log_info(c("brown cow", "blue horse"))
readLines(logfile)
vcr_log_info(c("brown cow", "blue horse", "green goat"))
readLines(logfile)

# standalone workflow
# set a file to log to
vcr_log_file((f <- tempfile()))
readLines(f) # empty

# log messages
vcr_log_info("hello world!")
readLines(logfile)
vcr_log_info("foo bar")
readLines(logfile)

# cleanup
unlink(f)
unlink(logfile)

Run the code above in your browser using DataLab