Learn R Programming

inlabru (version 2.11.1)

bru_log_message: Add a log message

Description

Adds a log message.

Usage

bru_log_message(
  ...,
  domain = NULL,
  appendLF = TRUE,
  verbosity = 1L,
  allow_verbose = TRUE,
  verbose = NULL,
  verbose_store = NULL,
  x = NULL
)

Value

bru_log_message returns invisible(x), where x is the updated bru_log

object, or NULL.

Arguments

...

For bru_log_message(), zero or more objects passed on to base::.makeMessage()

domain

Domain for translations, passed on to base::.makeMessage()

appendLF

logical; whether to add a newline to the message. Only used for verbose output.

verbosity

numeric value describing the verbosity level of the message

allow_verbose

Whether to allow verbose output. Must be set to FALSE until the options object has been initialised.

verbose

logical, numeric, or NULL; local override for verbose output. If NULL, the global option bru_verbose or default value is used. If FALSE, no messages are printed. If TRUE, messages with verbosity \(\le 1\) are printed. If numeric, messages with verbosity \(\le\) verbose are printed.

verbose_store

Same as verbose, but controlling what messages are stored in the global log object. Can be controlled via the bru_verbose_store with bru_options_set().

x

A bru_log object. If NULL, refers to the global inlabru log.

See Also

Other inlabru log methods: bru_log(), bru_log_bookmark(), bru_log_new(), bru_log_offset(), bru_log_reset()

Examples

Run this code
if (interactive()) {
  code_runner <- function() {
    local_bru_options_set(
      # Show messages up to and including level 2 (default 0)
      bru_verbose = 2,
      # Store messages to an including level 3 (default Inf, storing all)
      bru_verbose_store = 3
    )

    bru_log_bookmark("bookmark 1")
    bru_log_message("Test message 1", verbosity = 1)
    bru_log_message("Test message 2", verbosity = 2)
    bru_log_bookmark("bookmark 2")
    bru_log_message("Test message 3", verbosity = 3)
    bru_log_message("Test message 4", verbosity = 4)

    invisible()
  }
  message("Run code")
  code_runner()
  message("Check log from bookmark 1")
  print(bru_log()["bookmark 1"])
  message("Check log from bookmark 2")
  print(bru_log()["bookmark 2"])
}

Run the code above in your browser using DataLab