log_close: Close the log

View source: R/logr.R

log_closeR Documentation

Close the log

Description

The log_close function closes the log file.

Usage

log_close()

Details

The log_close function terminates logging. As part of the termination process, the function prints any outstanding warnings to the log. Errors are printed at the point at which they occur. But warnings can be captured only at the end of the logging session. Therefore, any warning messages will only be printed at the bottom of the log.

The function also prints the log footer. The log footer contains a date-time stamp of when the log was closed.

Value

None

See Also

log_open to open the log, and log_print for printing to the log.

Examples

# Create temp file location
tmp <- file.path(tempdir(), "test.log")

# Open log
lf <- log_open(tmp)

# Send message to log
log_print("High Mileage Cars Subset")

# Perform operations
hmc <- subset(mtcars, mtcars$mpg > 20)

# Print data to log
log_print(hmc)

# Close log
log_close()

# View results
writeLines(readLines(lf))

logr documentation built on Nov. 10, 2023, 1:07 a.m.