Learn R Programming

ParallelLogger (version 3.0.0)

addDefaultEmailLogger: Add the default e-mail logger

Description

Add the default e-mail logger

Usage

addDefaultEmailLogger(
  mailSettings,
  label = Sys.info()["nodename"],
  name = "DEFAULT_EMAIL_LOGGER",
  test = FALSE
)

Arguments

mailSettings

Arguments to be passed to the send.mail function in the mailR package (except subject and body).

label

A label to be used in the e-mail subject to identify a run. By default the name of the computer is used.

name

A name for the logger.

test

If TRUE, a message will be displayed on the console instead of sending an e-mail.

Details

Creates a logger that writes to e-mail using the "FATAL" threshold and the layoutEmail layout. This function uses the mailR package. Please make sure your e-mail settings are correct by using the mailR package before using those settings here. ParallelLogger will not display any messages if something goes wrong when sending the e-mail.

Examples

Run this code
# NOT RUN {
mailSettings <- list(
  from = "someone@gmail.com",
  to = c("someone_else@gmail.com"),
  smtp = list(
    host.name = "smtp.gmail.com",
    port = 465,
    user.name = "someone@gmail.com",
    passwd = "super_secret!",
    ssl = TRUE
  ),
  authenticate = TRUE,
  send = TRUE
)

# 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")

unregisterLogger("DEFAULT_EMAIL_LOGGER")
# }

Run the code above in your browser using DataLab