logger: Creates a new logger object or returns the "racasLogger"

View source: R/logger.R

loggerR Documentation

Creates a new logger object or returns the "racasLogger"

Description

Optionally creates a new logger or returns a logger stored in the racas namespace. Most inputs are passed through to createLogger. The default call 'logger()' will compare the field racas::racasLogger$envir with the current list of frames in the call stack. If the environment in the racasLogger matches one of the environments in the current call stack, then the racasLogger is returned.

Usage

logger(racas = TRUE, reset = FALSE, envir = parent.frame(), ...)

Arguments

racas

Boolean marking if racasLogger should be used, or if it is just passed to createLogger

reset

Boolean marking if racasLogger should be reset. Ignored if racas is FALSE

envir

name of the log file to write to (default: "acas.log")

...

further arguments to be passed to createLogger

Value

object of class Logger

Examples

#From a fresh logger (myLogger <- createLogger())

#Will write
myLogger$error("a warn statement")
myLogger$warn("a warn statement")

#Won't write items that are below "WARN" in names(logging::loglevels)
myLogger$debug("a debug statement")
myLogger$info("a warn statement")

#Creating a logger with logLevel = "DEBUG"
myLogger <- createLogger(logName = "com.mycompany.newprocessor",
                         logFileName = "newprocessor.log",
                         logLevel = "DEBUG")

#Now it will log debug and info statements
myLogger$debug("a debug statement")
myLogger$info("a warn statement")

mcneilco/racas documentation built on April 19, 2024, 1:12 p.m.