R/debug_print.R

Defines functions debug_print

Documented in debug_print

#' Debug Print Function
#'
#' Prints a value to the console with a timestamp if the 'DEBUG' environment variable is set.
#' This function is useful for conditional debugging output in R projects.
#'
#' @param value The R object to be printed.
#'
#' @keywords internal
#'
debug_print <- function(value) {
  # Check if the 'DEBUG' environment variable has a non-zero length, indicating debugging is active.
  if (nchar(Sys.getenv("DEBUG")) > 0) {
    # Print a debug header with the current timestamp.
    message("--- DEBUG ", Sys.time())
    # Print the provided value.
    print(value)
  }
}

Try the myownrobs package in your browser

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

myownrobs documentation built on Nov. 5, 2025, 5:52 p.m.