Skip to contents

Call once near the top of a script to make the logger package (https://daroczig.github.io/logger/) render through logtree. It registers layout_logtree() as logger's layout and logger::appender_void as its appender for namespace, so from then on every logger::log_info() / log_warn() / ... call in that namespace prints as a logtree leaf. This is the one-call form of the manual logger::log_layout() + logger::log_appender() pairing.

Usage

logtree_logger(namespace = "global", threshold = TRUE)

Arguments

namespace

logger namespace to route. Default "global", the namespace a bare logger::log_info("x") uses.

threshold

Open logger's threshold to TRACE for namespace so logtree_threshold() is the only gate? Default TRUE.

Value

NULL, invisibly.

Details

With threshold = TRUE (the default) it also opens logger's own threshold to TRACE for the namespace. logger gates on its threshold before the layout runs, so without this a logger::log_debug() would never reach logtree; opening it makes logtree_threshold() the single effective gate.

Bridge only: it does not install error handling. Wrap the run body in with_logging() as well when you want failed-run elevation and a summary line. The change is persistent for the session (matching logger's own global configuration style); there is no automatic teardown.

See also

layout_logtree() for the underlying layout, with_logging() for top-level error handling.

Examples

if (requireNamespace("logger", quietly = TRUE)) {
  logtree_reset()
  logtree_logger(namespace = "logtree_demo")
  log_step("Demo step")
  logger::log_info("hello", namespace = "logtree_demo")
}
#>  Demo step
#> ├─  hello
#> └─  Done  0.00s