Skip to contents

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

Usage

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/RtmpI4bEze/log/test.log 
#> Working Directory: /tmp/.tmpGy5KKX/docs/logr/1.4.1/src/docs/reference 
#> User Name: runner 
#> R Version: 4.6.2 (2026-10-29) 
#> Machine: runnervm48cm3 x86_64 
#> Operating System: Linux 7.0.0-1017-azure #17~24.04.1-Ubuntu SMP PREEMPT Thu Sep 24 18:46:57 UTC 2026 
#> Base Packages: stats graphics grDevices utils datasets methods base 
#> Other Packages: logr_1.4.1 common_1.1.5 
#> Log Start Time: 2026-10-29 23:27:01.482387 
#> ========================================================================= 
#> 
#> Before suspend 
#> 
#> NOTE: Log Print Time:  2026-10-29 23:27:01.484458 
#> NOTE: Elapsed Time: 0.0015099048614502 secs 
#> 
#> ========================================================================= 
#> Log suspended 
#> ========================================================================= 
#> 
#> Autolog: FALSE 
#> Log Path: /tmp/RtmpI4bEze/log/test.log 
#> Msg Path: /tmp/RtmpI4bEze/log/test.msg 
#> Show Notes: TRUE 
#> Blank After: TRUE 
#> Traceback: TRUE 
#> Status: open 
#> Tidylog: 
#> Log Time: 2026-10-29 23:27:01.484458 
#> Start Time: 2026-10-29 23:27:01.482948 
#> Suspend Time: 2026-10-29 23:27:01.488889 
#> Elapsed Time: 0.00443172454833984 
#> 

# Resume log
log_resume(lf)
#> [1] "/tmp/RtmpI4bEze/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/RtmpI4bEze/log/test.log 
#> Working Directory: /tmp/.tmpGy5KKX/docs/logr/1.4.1/src/docs/reference 
#> User Name: runner 
#> R Version: 4.6.2 (2026-10-29) 
#> Machine: runnervm48cm3 x86_64 
#> Operating System: Linux 7.0.0-1017-azure #17~24.04.1-Ubuntu SMP PREEMPT Thu Sep 24 18:46:57 UTC 2026 
#> Base Packages: stats graphics grDevices utils datasets methods base 
#> Other Packages: logr_1.4.1 common_1.1.5 
#> Log Start Time: 2026-10-29 23:27:01.482387 
#> ========================================================================= 
#> 
#> Before suspend 
#> 
#> NOTE: Log Print Time:  2026-10-29 23:27:01.484458 
#> NOTE: Elapsed Time: 0.0015099048614502 secs 
#> 
#> =========================================================================
#> Log Suspended: 2026-10-29 23:27:01.488889
#> Log Resumed: 2026-10-29 23:27:01.493843
#> Elapsed Time: 0 00:00:00
#> =========================================================================
#> 
#> After suspend 
#> 
#> NOTE: Log Print Time:  2026-10-29 23:27:01.496342 
#> NOTE: Elapsed Time: 0.00157380104064941 secs 
#> 
#> ========================================================================= 
#> Log End Time: 2026-10-29 23:27:01.497519 
#> Log Elapsed Time: 0 00:00:00 
#> =========================================================================