Learn R Programming

emil (version 2.2.10)

log_message: Print a timestamped and indented log message

Description

To suppress messages below a given indentation level set the global option setting emil_max_indent, as in the example below.

Usage

log_message(indent = 1, ..., time = TRUE, domain = "R-emil",
  appendLF = TRUE)

Arguments

indent

Indentation level. Messages with indent=0 are suppressed.

...

Sent to sprintf.

time

Whether or not to print timestamp.

domain

See message.

appendLF

Whether to finish the message with a linebreak or not.

Examples

Run this code
# NOT RUN {
equipment <- c("flashlight", "snacks", "pick")
{
    log_message(1, "Begin descent")
    log_message(2, "Oh no, forgot the %s!", sample(equipment, 1))
    log_message(2, "Hello? Can you throw it down to me?", time=FALSE)
    log_message(1, "Aw shucks, I'm coming back up.")
}

for(verbose in c(TRUE, FALSE)){
    cat("It's", verbose, "\n")
    for(i in 0:3)
        log_message(indent(verbose, i), "Down")
}

options(emil_max_indent = 2)
for(i in 1:3)
    log_message(i, "Down")
# }

Run the code above in your browser using DataLab