createLogger: Creates a new logger

View source: R/logger.R

createLoggerR Documentation

Creates a new logger

Description

Creates a new logger

Usage

createLogger(logName = "com.default.logger", logFileName = "racas.log",
  logDir = racas:::applicationSettings$server.log.path,
  logLevel = racas:::applicationSettings$server.log.level,
  envir = environment(), logToConsole = FALSE, ...)

Arguments

logName

Name for the logger output line within the log file (default: "com.default.logger)

logFileName

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

logDir

name directory to write to (default: racas::applicationSettings$server.log.path)

logLevel

the level at which to write logs (default: racas::applicationSettings$server.log.level, see names(logging::loglevels))

envir

an environment to attach to the object

Value

object of class logger

Examples

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

#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.