R/helpers.R

Defines functions log_fatal log_error log_warn log_info log_debug log_trace

Documented in log_debug log_error log_fatal log_info log_trace log_warn

#' Log a trace message
#'
#' Log messages will only be emitted if the log priority matches or is higher
#' than the priority of your message
#'
#' @param message your message to log
#' @param ... more elements of the message, to be concatenated with the message
#'
#' @return invisibly returns TRUE/FALSE
#' @examples
#' \dontrun{
#' log_trace("This is a trace message")
#' Sys.setenv("LOG_LEVEL" = "TRACE")
#' log_trace("This is a trace message")
#' }
#' @export
log_trace <- function(message, ...) {
  log_msg("TRACE", message, ...)
}

#' Log a debug message
#'
#' Log messages will only be emitted if the log priority matches or is higher
#' than the priority of your message
#'
#' @param message your message to log
#' @param ... more elements of the message, to be concatenated with the message
#'
#' @return invisibly returns TRUE/FALSE
#' @examples
#' \dontrun{
#' log_debug("This is a debug message")
#' Sys.setenv("LOG_LEVEL" = "TRACE")
#' log_debug("This is a debug message")
#' }
#' @export
log_debug <- function(message, ...) {
  log_msg("DEBUG", message, ...)
}

#' Log an info message
#'
#' Log messages will only be emitted if the log priority matches or is higher
#' than the priority of your message
#'
#' @param message your message to log
#' @param ... more elements of the message, to be concatenated with the message
#'
#' @return invisibly returns TRUE/FALSE
#' @examples
#' \dontrun{
#' log_info("This is an info message")
#' Sys.setenv("LOG_LEVEL" = "TRACE")
#' log_info("This is an info message")
#' }
#' @export
log_info <- function(message, ...) {
  log_msg("INFO", message, ...)
}

#' Log a warning message
#'
#' Log messages will only be emitted if the log priority matches or is higher
#' than the priority of your message
#'
#' @param message your message to log
#' @param ... more elements of the message, to be concatenated with the message
#'
#' @return invisibly returns TRUE/FALSE
#' @examples
#' \dontrun{
#' log_warn("This is a warning message")
#' Sys.setenv("LOG_LEVEL" = "TRACE")
#' log_warn("This is a warning message")
#' }
#' @export
log_warn <- function(message, ...) {
  log_msg("WARN", message, ...)
}

#' Log an error message
#'
#' Log messages will only be emitted if the log priority matches or is higher
#' than the priority of your message
#'
#' @param message your message to log
#' @param ... more elements of the message, to be concatenated with the message
#'
#' @return invisibly returns TRUE/FALSE
#' @examples
#' \dontrun{
#' log_error("This is an error message")
#' Sys.setenv("LOG_LEVEL" = "TRACE")
#' log_error("This is an error message")
#' }
#' @export
log_error <- function(message, ...) {
  log_msg("ERROR", message, ...)
}


#' Log a fatal message
#'
#' Log messages will only be emitted if the log priority matches or is higher
#' than the priority of your message
#'
#' @param message your message to log
#' @param ... more elements of the message, to be concatenated with the message
#'
#' @return invisibly returns TRUE/FALSE
#' @examples
#' \dontrun{
#' log_fatal("This is a fatal message")
#' Sys.setenv("LOG_LEVEL" = "TRACE")
#' log_fatal("This is a fatal message")
#' }
#' @export
log_fatal <- function(message, ...) {
  log_msg("FATAL", message, ...)
}

Try the rlog package in your browser

Any scripts or data that you put into this service are public.

rlog documentation built on March 19, 2026, 1:06 a.m.