log_result <- function(result) {
if (!requireNamespace("logger", quietly = TRUE)) {
return(invisible(result))
}
pass_level <- getOption("CHEX_PASS_LOG_LEVEL", logger::SUCCESS)
fail_level <- getOption("CHEX_FAIL_LOG_LEVEL", logger::WARN)
description <- description(result)
for (i in vec_seq_along(result)) {
res <- result[i]
desc <- description[i]
level <- if (res == PASS) {
pass_level
} else if (res == FAIL) {
fail_level
} else {
next
}
logger::log_level(level, logger::skip_formatter(desc), namespace = "chex")
}
invisible(result)
}
init_logging <- function() {
if (!requireNamespace("logger", quietly = TRUE)) {
return(invisible())
}
try(silent = TRUE, {
namespaces <- get(
"namespaces", envir = asNamespace("logger"), mode = "environment"
)
if (!exists("chex", namespaces)) {
logger::log_appender(identity, namespace = "chex")
}
})
invisible()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.