library(logr)
# Create temp file location
tmp <- file.path(tempdir(), "test.log")
# Open log
lf <- log_open(tmp)
# Send warning message to log
log_warning("Here is a warning")
# Close log
log_close()
# Retrieve warnings
res <- get_warnings()
# View results
res
# [1] "Warning: Here is a warning"
Run the code above in your browser using DataLab