A function to reopen and resume writing to a log file that has been suspended.

log_resume(file_name = NULL)

Arguments

file_name

The name of the log file to resume. If the file_name parameter is not supplied, the function will look in the current session for the original name and path of the log. If that name and path is not found, an error will be generated.

Value

The path of the log.

See also

log_suspend for suspending the log, and log_close to close the log.

Examples

library(logr)

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

# Open log
lf <- log_open(tmp)

# Send message to log
log_print("Before suspend")
#> Before suspend 

# Suspend log
log_suspend()
#> Log suspended

# View suspended log
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:06.016744 
#> ========================================================================= 
#> 
#> Before suspend 
#> 
#> NOTE: Log Print Time:  2025-10-14 20:31:06.017846 
#> NOTE: Elapsed Time: 0.000792026519775391 secs 
#> 
#> ========================================================================= 
#> Log suspended 
#> ========================================================================= 
#> 
#> Autolog: FALSE 
#> Log Path: /tmp/RtmpORwY5l/log/test.log 
#> Msg Path: /tmp/RtmpORwY5l/log/test.msg 
#> Show Notes: TRUE 
#> Blank After: TRUE 
#> Traceback: TRUE 
#> Status: open 
#> Tidylog: 
#> Log Time: 2025-10-14 20:31:06.017846 
#> Start Time: 2025-10-14 20:31:06.017054 
#> Suspend Time: 2025-10-14 20:31:06.019881 
#> Elapsed Time: 0.00203585624694824 
#> 

# Resume log
log_resume(lf)
#> [1] "/tmp/RtmpORwY5l/log/test.log"

# Print data to log
log_print("After suspend")
#> After suspend 

# Close log
log_close()

# 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:06.016744 
#> ========================================================================= 
#> 
#> Before suspend 
#> 
#> NOTE: Log Print Time:  2025-10-14 20:31:06.017846 
#> NOTE: Elapsed Time: 0.000792026519775391 secs 
#> 
#> =========================================================================
#> Log Suspended: 2025-10-14 20:31:06.019881
#> Log Resumed: 2025-10-14 20:31:06.022421
#> Elapsed Time: 0 00:00:00
#> =========================================================================
#> 
#> After suspend 
#> 
#> NOTE: Log Print Time:  2025-10-14 20:31:06.023835 
#> NOTE: Elapsed Time: 0.000854253768920898 secs 
#> 
#> ========================================================================= 
#> Log End Time: 2025-10-14 20:31:06.024491 
#> Log Elapsed Time: 0 00:00:00 
#> =========================================================================