logger: Pipe-Capable Log Messages

Description Usage Arguments Options Examples

View source: R/misc.R

Description

Writes a log message, suitable for use inside pipes, meaning that the first argument is passed through untouched. The log message is processed using glue::glue, and you can reference the incoming data as .data inside the log message.

Usage

1
logger(.data = NULL, msg = "", level = "INFO")

Arguments

.data

This argument is returned as-is.

msg

The log message, processed using glue::glue. You can refernce the data passed in via .data.

level

The log level, default is "INFO" and possible values include "DEBUG", "INFO", "WARNING", "ERROR", and "FATAL".

Options

You can set the maximum debug level and the log output locations using the global options grkmisc.log_level and grkmisc.log_output. The defaults are "INFO" and stdout() respectively.

Examples

1
2
3
4
5
6
library(dplyr)
iris %>%
  logger("Starting with {nrow(.data)} rows") %>%
  filter(Species == "setosa") %>%
  logger("Filtered to {nrow(.data)} rows and {ncol(.data)} columns") %>%
  head()

GerkeLab/grkmisc documentation built on Feb. 23, 2020, 6:50 a.m.