-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathscat.R
30 lines (30 loc) · 845 Bytes
/
scat.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#' Display debugging text
#'
#' If \code{getOption('DEBUG')==TRUE}, write text to STDOUT and flush so that
#' the text is immediately displayed. Otherwise, do nothing.
#'
#'
#' @param \dots Arguments passed to \code{cat}
#' @return NULL (invisibly)
#' @author Gregory R. Warnes \email{greg@@warnes.net}
#' @seealso \code{\link[base]{cat}}
#' @keywords print
#' @examples
#'
#' options(DEBUG = NULL) # makee sure DEBUG isn't set
#' scat("Not displayed")
#'
#' options(DEBUG = TRUE)
#' scat("This will be displayed immediately (even in R BATCH output \n")
#' scat("files), provided options()$DEBUG is TRUE.")
#' @export
scat <- function(...) {
DEBUG <- options()$DEBUG
if (!is.null(DEBUG) && DEBUG) {
cat("### ", file = stderr())
cat(..., file = stderr())
cat(" ###\n", file = stderr())
flush(stderr())
}
invisible(NULL)
}