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
#'
#' @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(message, "TRACE")
}

#' 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
#'
#' @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(message, "DEBUG")
}

#' 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
#'
#' @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(message, "INFO")
}

#' 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
#'
#' @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(message, "WARN")
}

#' 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
#'
#' @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(message, "ERROR")
}


#' 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
#'
#' @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(message, "FATAL")
}

Try the rlog package in your browser

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

rlog documentation built on Feb. 24, 2021, 5:08 p.m.