Learn R Programming

loggr (version 0.3)

log_info: Signal Event to Log File Handlers.

Description

Create and signal an DEBUG, INFO, WARN, ERROR or CRITICAL condition. The appropriate condition handlers listening for the type of event signalled will be notified. The message can be wrapped in a one sided formula, in which case string interpolation will be used.

Usage

log_info(message, ...)

log_error(message, ...)

log_debug(message, ...)

log_warn(message, ...)

log_critical(message, ...)

log_with_level(message, ..., .level)

Arguments

message

character: the message to log.

...

additional data to log (ignored by default formatter)

.level

character the logging level.

Using log functions in pipeline expressions

It is possible to use logging as part of a pipeline by specifying the message as a two-sided formula with the dot placeholder as left-hand side, i.e. . ~ message. In this case the value can be referenced in string interpolations as `.`. Since the piped object is placed as the first argument, the message is now technically the first element in ... and is identified if this is a formula in the appropriate form.

Details

The function log_with_level is not intended for direct use. Rather the other functions redirect to this function with the appropriate level set.

Examples

Run this code
# NOT RUN {
log_file("console")
log_info("Basic information.")

dollars <- 10
log_info(~ "I have ${dollars} dollars.")

# }
# NOT RUN {
library(magrittr)
log_file("console")

iris_sub <-
  iris %>%
  subset(Species == "versicolor") %>%
  log_info(. ~ "Keeping ${NROW(.)} versicolor rows.") %>%
  transform(Ratio = Sepal.Length/Sepal.Width)
# }

Run the code above in your browser using DataLab