inbuilt-actions {logging} | R Documentation |
Predefined(sample) handler actions
Description
When you define a handler, you specify its name and the associated action. A few predefined actions described below are provided.
Usage
writeToConsole(msg, handler, ...)
writeToFile(msg, handler, ...)
Arguments
msg |
A formated message to handle. |
handler |
The handler environment containing its options. You can register the same action to handlers with different properties. |
... |
parameters provided by logger system to interact with the action. |
Details
A handler action is a function that accepts a formated message and handler configuration.
Messages passed are filtered already regarding loglevel.
... parameters are used by logging system to interact with the action. ... can contain dry key to inform action that it meant to initialize itself. In the case action should return TRUE if initialization succeded.
If it's not a dry run ... contain the whole preformated logging.record. A logging.record is a named list and has following structure:
- msg
contains the real formatted message
- level
message level as numeric
- levelname
message level name
- logger
name of the logger that generated it
- timestamp
formatted message timestamp
writeToConsole
detects if crayon package is available and uses it
to color messages. The coloring can be switched off by means of configuring
the handler with color_output option set to FALSE.
writeToFile
action expects file path to write to under
file key in handler options.
Examples
## define your own function and register it with a handler.
## author is planning a sentry client function. please send
## any interesting function you may have written!