Add the default e-mail logger
addDefaultEmailLogger(
mailSettings,
label = Sys.info()["nodename"],
name = "DEFAULT_EMAIL_LOGGER",
test = FALSE
)
Arguments to be passed to the sendmail
function in the sendmailR
package (except
subject and msg).
A label to be used in the e-mail subject to identify a run. By default the name of the computer is used.
A name for the logger.
If TRUE, a message will be displayed on the console instead of sending an e-mail.
Creates a logger that writes to e-mail using the "FATAL" threshold and the
layoutEmail
layout. This function uses the sendmailR
package. Please make sure
your e-mail settings are correct by using the sendmailR
package before using those settings here.
ParallelLogger
will not display any messages if something goes wrong when sending the e-mail.
To use a GMail account, make sure to enable 2-step verification on your
Google account (see 'Security'). Click on 2-Step Verification, and
scroll down to 'App passwords'. Here, you can create an app-specific password
to be used with ParallelLogger
. You can set
host.name = "smtp.gmail.com:587"
, and be sure to use
engine = "curl"
.
mailSettings <- list(
from = "someone@gmail.com",
to = "someone_else@gmail.com",
engine = "curl",
engineopts = list(
username = "someone@gmail.com",
password = "Secret!"
),
control = list(
host.name = "smtp.gmail.com:587"
)
)
# Setting test to TRUE in this example so we don't really send an e-mail:
addDefaultEmailLogger(mailSettings, "My R session", test = TRUE)
logFatal("Something bad")
#> You've got mail:
#> To:
#> someone_else@gmail.com
#>
#> Subject:
#> [My R session] FATAL
#>
#> Body:
#> Message: Something bad
#> Time: 2025-03-28 09:38:02
#> Level: FATAL
#> Stack trace:
#> 44: logFatal("Something bad")
#> 43: eval(expr, envir)
#> 42: eval(expr, envir)
#> 41: withVisible(eval(expr, envir))
#> 40: withCallingHandlers(code, message = function (cnd)
#> {
#> watcher$capture_plo
#> 39: eval(call)
#> 38: eval(call)
#> 37: with_handlers({
#> for (expr in tle$exprs) {
#> ev <- withVisible(eval(
#> 36: doWithOneRestart(return(expr), restart)
#> 35: withOneRestart(expr, restarts[[1]])
#> 34: withRestartList(expr, restarts[-nr])
#> 33: doWithOneRestart(return(expr), restart)
#> 32: withOneRestart(withRestartList(expr, restarts[-nr]), restarts[[nr]])
#> 31: withRestartList(expr, restarts)
#> 30: withRestarts(with_handlers({
#> for (expr in tle$exprs) {
#> ev <- with
#> 29: evaluate::evaluate(code, child_env(env), new_device = TRUE, output_handler
#> 28: downlit::evaluate_and_highlight(code, fig_save = fig_save_topic, env = eval
#> 27: highlight_examples(code, topic, env = env)
#> 26: run_examples(tags$tag_examples[[1]], env = if (is.null(examples_env)) NULL
#> 25: data_reference_topic(topic, pkg, examples_env = examples_env, run_dont_run
#> 24: withCallingHandlers(data_reference_topic(topic, pkg, examples_env = example
#> 23: .f(.x[[i]], ...)
#> 22: call_with_cleanup(map_impl, environment(), .type, .progress, n, names, i)
#> 21: withCallingHandlers(expr, error = function(cnd) {
#> if (i == 0) {
#> }
#>
#> 20: with_indexed_errors(i = i, names = names, error_call = .purrr_error_call, c
#> 19: map_("list", .x, .f, ..., .progress = .progress)
#> 18: purrr::map(topics, build_reference_topic, pkg = pkg, lazy = lazy, examples_
#> 17: withCallingHandlers(code, purrr_error_indexed = function(err) {
#> cnd_sign
#> 16: unwrap_purrr_error(purrr::map(topics, build_reference_topic, pkg = pkg, laz
#> 15: build_reference(pkg, lazy = lazy, examples = examples, run_dont_run = run_d
#> 14: build_site_local(pkg = pkg, examples = examples, run_dont_run = run_dont_ru
#> 13: pkgdown::build_site(...)
#> 12: (function (..., cli_colors, hyperlinks, pkgdown_internet)
#> {
#> options(cli.
#> 11: (function (what, args, quote = FALSE, envir = parent.frame())
#> {
#> if (!is.
#> 10: base::do.call(base::do.call, base::c(base::readRDS("/var/folders/d5/7zcm15t
#> 9: base::saveRDS(base::do.call(base::do.call, base::c(base::readRDS("/var/fold
#> 8: base::withCallingHandlers({
#> NULL
#> base::saveRDS(base::do.call(base::do
#> 7: doTryCatch(return(expr), name, parentenv, handler)
#> 6: tryCatchOne(expr, names, parentenv, handlers[[1]])
#> 5: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
#> 4: doTryCatch(return(expr), name, parentenv, handler)
#> 3: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), names
#> 2: tryCatchList(expr, classes, parentenv, handlers)
#> 1: base::tryCatch(base::withCallingHandlers({
#> NULL
#> base::saveRDS(base::d
unregisterLogger("DEFAULT_EMAIL_LOGGER")
#> [1] TRUE