File: inbuilt-actions.Rd

package info (click to toggle)
r-cran-logging 0.10-108-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 220 kB
  • sloc: sh: 13; makefile: 2
file content (57 lines) | stat: -rw-r--r-- 2,040 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{inbuilt-actions}
\alias{inbuilt-actions}
\alias{writeToConsole}
\alias{writeToFile}
\title{Predefined(sample) handler actions}
\usage{
writeToConsole(msg, handler, ...)

writeToFile(msg, handler, ...)
}
\arguments{
\item{msg}{A formated message to handle.}

\item{handler}{The handler environment containing its options. You can
register the same action to handlers with different properties.}

\item{...}{parameters provided by logger system to interact with the action.}
}
\description{
When you define a handler, you specify its name and the associated action.
A few predefined actions described below are provided.
}
\details{
A handler action is a function that accepts a formated message and handler
configuration.

Messages passed are filtered already regarding loglevel.

\dots parameters are used by logging system to interact with the action. \dots can
contain \var{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 \dots contain the whole preformated \var{logging.record}.
A \var{logging.record} is a named list and has following structure:
\describe{
  \item{msg}{contains the real formatted message}
  \item{level}{message level as numeric}
  \item{levelname}{message level name}
  \item{logger}{name of the logger that generated it}
  \item{timestamp}{formatted message timestamp}
}

\code{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 \var{color_output} option set to FALSE.

\code{writeToFile} action expects file path to write to under
 \var{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!

}