logR: Detailed logging of R expressions

Description Usage Arguments Value Side effects Database setup Fatal errors Note See Also

Description

Complete logging solution. Writes to database expressions metadata before its evaluation. Evalutes with timing and warning/error/interrupt/messages catching. Updates database entry for processing details: in/out rows, custom metadata, messages/warning/error message. Email on alerts.

Usage

1
2
3
4
5
6
logR(expr, lazy = TRUE, parent = getOption("logR.id", NA_integer_),
  alert = TRUE, in_rows = NA_integer_, meta = getOption("logR.meta"),
  silent = getOption("logR.silent"), mail = getOption("logR.mail"),
  mail_args = getOption("logR.mail_args"), boolean = FALSE,
  .conn = getOption("logR.conn"), .schema = getOption("logR.schema"),
  .table = getOption("logR.table"), .log = getOption("logR.log"))

Arguments

expr

expression to be evaluted with logging.

lazy

logical default TRUE, use FALSE when passing language object to expr argument.

parent

integer default NA, the 'logr_id' of the parent logged process.

alert

logical, should be alert flag suppressed on warning/error, including suppressing email notification.

in_rows

integer input DF/DT nrow, logR can only guess out_rows.

meta

list or a function that will result such list, list of custom fields, each of length 1, list be always the same, fill missing with NA. Default getOption("logR.meta",list()) means no meta columns. If the input is a function then it is evaluated with default values for all argument, and should return a valid list. If you want to change element you need to alter table before or recreate with logR_schema.

silent

logical, if default getOption("logR.silent",TRUE) it will not raise warning or error but only log them.

mail

logical if TRUE then on alert the email will be send. Requires mail_args to be provided. Default getOption("logR.mail",FALSE).

mail_args

list - mail not implemented yet.

boolean

logical, default FALSE, when TRUE only 'status=="success"' will be returned.

.conn

DBI connection. Default to getOption("logR.conn",NULL).

.schema

character scalar, location in database to store logs, default getOption("logR.schema").

.table

character scalar, location in database to store logs, default getOption("logR.table").

.log

logical escape parameter, set to FALSE to suppress logR process and just execute a call, default to getOption("logR.log",TRUE).

Value

Result of evaluated expr, NULL in case of error or interrupt. If silent = FALSE then error/warning/interrupt will raise warning/error.

Side effects

Database setup

You can create db objects automatically using logR_schema function or manually using code from schema_sql.

Fatal errors

If your R function will manage to kill whole R session you will see that status entry in log table will not get updated and it will stay as NA. It might be worth to schedule a watcher task to detect such cases, see logR_watcher.

Note

Only first warning/message will be logged to database and send on email.

See Also

logR_schema, logR_query


jangorecki/logR documentation built on May 18, 2019, 12:24 p.m.