dcDebug: Possibly print a debugging message

Description Usage Arguments Author(s) Examples

View source: R/dc.R

Description

dcDebug() prints a message, if its first argument exceeds 0. Many dc functions decrease the debug level by 1 when they call other functions, so the effect is a nesting, with more space for deeper function level.

Usage

1
dcDebug(debug = 0, ..., style = "plain", unindent = 0)

Arguments

debug

an integer, less than or equal to zero for no message, and greater than zero for increasing levels of debugging. Values greater than 4 are treated like 4.

...

one or several character or other values to be printed, analogous to the ... argument of cat().

style

either a string or a function. If a string, it must be "plain" (the default) for plain text, "bold", "italic", "red", "green" or "blue" (with obvious meanings). If style is a function, it must prepend and postpend the text with control codes, as in the cyan-coloured example; note that crayon provides many functions that work well for style.

unindent

Number of levels to un-indent, e.g. it is common to set this to -1 for messages about entering or exiting a function.

Author(s)

Dan Kelley

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
foo <- function(debug=1)
{
   dcDebug(debug, "in foo, about to call bar()\n")
   bar(debug=debug-1)
   dcDebug(debug, "in foo, after calling bar()\n")
}
bar <- function(debug=1)
{
   dcDebug(debug, "in bar()\n")
}
foo(debug=2)
foo(debug=1)
foo(debug=0)

dankelley/dac documentation built on June 4, 2020, 11:45 p.m.