handlers-management: Add a handler to or remove one from a logger.

Description Usage Arguments Details


Use this function to maintain the list of handlers attached to a logger.

addHandler and removeHandler are also offered as methods of the Logger S4 class.


addHandler(handler, ..., logger = "")

removeHandler(handler, logger = "")



The name of the handler, or its action


Extra parameters, to be stored in the handler list

... may contain extra parameters that will be passed to the handler action. Some elements in the ... will be interpreted here.


the name of the logger to which to attach the new handler, defaults to the root logger.


Handlers 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

action(msg, handler)

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.

periscope documentation built on July 8, 2020, 7:18 p.m.