There are situations when you want to control log printing globally. For those cases, logr has some global options.

The option “logr.on” accepts a TRUE or FALSE value, and determines whether the logr log is on or off. The option “logr.notes” also accepts a TRUE or FALSE value, and determines whether to include notes in the log. Both of these global options will override any local settings.

The following code sample demonstrates how to use these options:

# Turn logger off 
options("logr.on" = FALSE)

# Turn logger on and show notes 
options("logr.on" = TRUE, "logr.notes" = TRUE)

# Turn off notes
options("logr.notes" = FALSE)

There is also a global option to turn on the autolog feature. Autolog will automatically print logging entries for many dplyr and tidyr functions. This option can greatly reduce the number of log_print() or put() statements needed to obtain a complete log. The autolog feature can be turned on or off by a parameter on the log_open() statement, or by the “logr.autolog” global option, as follows:

# Turn autolog on
options("logr.autolog" = TRUE)

# Turn autolog off
options("logr.autolog" = FALSE)

If you want to minimize the size of the log, there is a global option called “compact” to remove any blank spaces between log entries. This setting essentially forces the “blank_after” parameter on log_print() to FALSE for all entries.

# Turn on compact option
options("logr.compact" = TRUE)

# Turn off compact option
options("logr.compact" = FALSE)

By default, logr will print a traceback of all error messages. In most cases, this is a useful feature to help you precisely identify the source of an error. In some cases, the traceback provides too much unnecessary information. The “logr.traceback” global option can be used to turn the traceback messaging on or off. The option accepts a TRUE or FALSE value, which will override anything set on log_open().

# Turn on traceback messaging
options("logr.traceback" = TRUE)

# Turn off traceback messaging
options("logr.traceback" = FALSE)

Next: Aliases for log_print()