Description Usage Arguments Details Examples
use these functions to maintain the list of handlers attached to a logger.
addHandler and removeHandler are also offered as methods of the Logger S4 class. in that case there is no logger argument.
1 2 | addHandler(handler, ..., logger = "")
removeHandler(handler, logger='')
|
handler |
the name of the handler, or its action |
... |
extra parameters for the action, to be stored in the handler list |
logger |
character parameter for the functional form: the name of the logger to which to attach the new handler, defaults to the root logger |
... may contain extra parameters that will be passed to the handler action. some elements in the ... will be interpreted here.
handler are implemented as environments. within a logger a handler is identified by its name and all handlers define at least the three variables:
all records at level lower than this are skipped.
a function getting a record and returning a string
a function accepting two parameters: a formatted log record and the handler itself. making the handler a parameter of the action allows us to have reusable action functions.
being an environment, a handler may define as many variables as you think you need. keep in mind the handler is passed to the action function, which can check for existence and can use all variables that the handler defines.
1 2 3 4 5 6 | logReset()
addHandler(writeToConsole)
names(getLogger()[['handlers']])
loginfo('test')
removeHandler('writeToConsole')
logwarn('test')
|
[1] "writeToConsole"
2018-03-19 04:20:04 INFO::test
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.