Stops every sink – console, files, and any of your own – from receiving events, without unregistering them. This is what a library that logs with logtree reaches for to keep its own test suite quiet, and what a script reaches for around a noisy section.
Details
Three things muting deliberately does not do:
It does not stop the run being recorded. Warnings and errors still reach the
logtree_summary()digest, so a muted run can still be asked what went wrong at the end – andlogtree_summary()still prints when you call it, since that output is one you asked for rather than one that happened to you. Thewith_logging()run-summary line, which you did not ask for, is silenced.It does not disturb step bookkeeping. Steps still open and close while muted, so depth is still correct when output comes back.
It does not survive... anything, actually: like registered sinks, and unlike the open-step stack, the mute flag is left alone by
logtree_reset(). Unmute explicitly.
The logtree.silent option sets the initial state when the package is
loaded, for silencing logtree from an .Rprofile or a test setup file; after
that these functions are in charge, so a later options(logtree.silent = )
has no effect.
See also
logtree_sink_remove() for taking a sink off altogether.
Examples
logtree_reset()
was <- logtree_mute()
f <- function() {
log_step("Load data")
log_warn("coerced 3 rows")
}
invisible(f()) # prints nothing
logtree_unmute()
# ... but the run was still recorded:
length(logtree_summary())
#>
#> ── Summary: 1 warning ──────────────────────────────────────────────────────────
#> ⚠ Load data › coerced 3 rows
#> [1] 1
# Restore whatever was in force before, rather than assuming it was off.
was <- logtree_mute()
if (!was) logtree_unmute()
