writeerror2log: Write errors to a log file

Description Usage Arguments Examples

View source: R/log.R

Description

Write errors to a log file

Usage

1
writeerror2log(condition, logfile, optionaltext = NULL)

Arguments

condition

warning or error condition as returned by tryCatch

logfile

character path to a log file

optionaltext

character additional text added after the timestamp

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Create a log file name
logfileexample <- file.path(tempdir(),"log.txt")
# Catch an error
 tryCatch({
     stop("There is an error in this exampe.")
 }, error = function(errorcondition){
            writeerror2log(errorcondition, logfileexample, "code: 123456")
 })
 # Read the log file
readLines(logfileexample)

EuropeanForestInstitute/tradeflows documentation built on Oct. 8, 2018, 10:05 a.m.