log_message: Print a timestamped and indented log message

Description Usage Arguments Author(s) Examples

View source: R/message.r

Description

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

Usage

1
2
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.

Author(s)

Christofer Bäcklin

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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")

Example output

Attaching package: 'emil'

The following object is masked from 'package:base':

    mode

25 Jan 22:18  Begin descent
25 Jan 22:18    Oh no, forgot the pick!
                Hello? Can you throw it down to me?
25 Jan 22:18  Aw shucks, I'm coming back up.
It's TRUE 
25 Jan 22:18  Down
25 Jan 22:18    Down
25 Jan 22:18      Down
25 Jan 22:18        Down
It's FALSE 
25 Jan 22:18  Down
25 Jan 22:18    Down
25 Jan 22:18      Down

emil documentation built on Aug. 1, 2018, 1:03 a.m.

Related to log_message in emil...