Skip to contents

The package writes an INFO+ trace to a session temp file (logger appender index 1) and echoes WARN+ to the console (index 2). Both logger::log_appender() and logger::log_threshold() default to index = 1, so the obvious two-line recipe silences the file and leaves the console untouched, which is the opposite of what anyone wants. This helper names the right index.

Usage

spatialkit_quiet(quiet = TRUE)

Arguments

quiet

TRUE (default) silences the console echo; FALSE restores the package default, WARN+. A logger threshold (logger::ERROR, or the value a previous call returned) sets that level instead, which is how to put back exactly what was in force rather than the default: old <- spatialkit_quiet(); spatialkit_quiet(old).

Value

Invisibly, the threshold that was in force before the change, a logger level that can be passed back as quiet.

Details

These are log records, not R conditions: suppressWarnings() and tryCatch(warning = ) do not see them. Conditions the package raises as real R warnings are unaffected by this function.

While a document is being knitted (R Markdown, Quarto, a pkgdown article) the console echo is also sent as an R message, because knitr does not capture what is written to the console's error stream and the cautions would otherwise be missing from the output. They appear as ## WARN [...] lines, and the chunk option message = FALSE, like suppressMessages(), keeps them out of the document. A line the package also raises as an R warning is not repeated, since the document shows the warning. Outside knitr nothing changes.

See also

Examples

old <- spatialkit_quiet()      # console echo off
spatialkit_quiet(old)          # back to whatever it was
spatialkit_quiet(FALSE)        # or back to the WARN+ default