Writes an error message to the log. Error will be written both to the log and the message file. For the log, the error will be written at the point the function is called. This function is used internally.

log_error(msg = NULL)

Arguments

msg

The message to log.

See also

log_warning to write a warning message to the log.

Examples

library(logr)

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

# Open log
lf <- log_open(tmp)

# Send error message to log
log_error("Here is a error")
#> Error: Here is a error
#> Error: Here is a error 

# Close log
log_close()
#> Log is not open.

# View results
writeLines(readLines(lf))
#> ========================================================================= 
#> Log Path: /tmp/RtmpORwY5l/log/test.log 
#> Working Directory: /cluster-data/user-homes/elizabethb/projects/prism-pkgdocs-build/installed-pkgs/priority-3/logr_1.3.9/docs/reference 
#> User Name: elizabethb 
#> R Version: 4.4.1 (2024-06-14) 
#> Machine: uat-uat-a2ai-cloud x86_64 
#> Operating System: Linux 6.2.0-1018-aws #18~22.04.1-Ubuntu SMP Wed Jan 10 22:54:16 UTC 2024 
#> Base Packages: stats graphics grDevices utils datasets methods base 
#> Other Packages: logr_1.3.9 common_1.1.3 
#> Log Start Time: 2025-10-14 20:31:04.479397 
#> ========================================================================= 
#> 
#> Error: Here is a error 
#> ========================================================================= 
#> Log End Time: 2025-10-14 20:31:04.481023 
#> Log Elapsed Time: 0 00:00:00 
#> =========================================================================