vcr_logging: vcr log file setup

Description Usage Arguments Examples

Description

vcr log file setup

Usage

1
2
3
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 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)

vcr documentation built on June 1, 2021, 1:06 a.m.