R/messager.R

Defines functions messager

Documented in messager

#' Print messages
#'
#' Conditionally print messages.
#'  Allows developers to easily control verbosity of functions,
#'  and meet Bioconductor requirements that dictate the message
#'  must first be stored to a variable before passing to \link[base]{message}.
#'
#'
#' @param v Whether to print messages or not.
#' @param parallel Whether to enable message print when wrapped
#' in parallelised functions.
#'
#' @return Null
#' @keywords internal
messager <- function(..., v = TRUE, parallel = FALSE) {
    if(isTRUE(parallel)){
      message_parallel <- function(...) {
        system(sprintf('echo "%s"', paste0(..., collapse = "")))
      }
        if(v) try({message_parallel(...)})
    } else {
        msg <- paste(...)
        if (v) try({message(msg)})
    }
}
neurogenomics/MultiEWCE documentation built on Sept. 28, 2024, 2:27 a.m.