Debian Codegraph @

man/FilterInject.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/Filter.R
3 \name{FilterInject}
4 \alias{FilterInject}
5 \title{Inject values into all events processed by a Logger/Appender}
6 \description{
7 Inject arbitrary values into all \link[=LogEvent]{LogEvents} processed
8 by a Logger/Appender. It is recommended to use filters that modify LogEvents
9 only with Loggers, but they will also work with Appenders.
10 }
11 \examples{
12 lg <- get_logger("test")
13
14 analyse <- function(){
15 lg$add_filter(FilterInject$new(type = "analysis"), "inject")
16 on.exit(lg$remove_filter("inject"))
17 lg$error("an error with forced custom 'type'-field")
18 }
19
20 analyse()
21 lg$error("an normal error")
22 lg$config(NULL) # reset config
23 }
24 \section{Super class}{
25 \code{\link[lgr:EventFilter]{lgr::EventFilter}} -> \code{FilterInject}
26 }
27 \section{Public fields}{
28 \if{html}{\out{<div class="r6-fields">}}
29 \describe{
30 \item{\code{values}}{a named \code{list} of values to be injected into each
31 \link{LogEvent} processed by this filter}
32 }
33 \if{html}{\out{</div>}}
34 }
35 \section{Methods}{
36 \subsection{Public methods}{
37 \itemize{
38 \item \href{#method-FilterInject-new}{\code{FilterInject$new()}}
39 \item \href{#method-FilterInject-clone}{\code{FilterInject$clone()}}
40 }
41 }
42 \if{html}{\out{<hr>}}
43 \if{html}{\out{<a id="method-FilterInject-new"></a>}}
44 \if{latex}{\out{\hypertarget{method-FilterInject-new}{}}}
45 \subsection{Method \code{new()}}{
46 Initialize a new FilterInject
47 \subsection{Usage}{
48 \if{html}{\out{<div class="r">}}\preformatted{FilterInject$new(..., .list = list())}\if{html}{\out{</div>}}
49 }
50
51 \subsection{Arguments}{
52 \if{html}{\out{<div class="arguments">}}
53 \describe{
54 \item{\code{..., .list}}{any number of named \R objects that will be injected as
55 custom fields into all \link[=LogEvent]{LogEvents} processed by the
56 Appender/Logger that this filter is attached to. See also
57 \code{\link[=with_log_value]{with_log_value()}}.}
58 }
59 \if{html}{\out{</div>}}
60 }
61 }
62 \if{html}{\out{<hr>}}
63 \if{html}{\out{<a id="method-FilterInject-clone"></a>}}
64 \if{latex}{\out{\hypertarget{method-FilterInject-clone}{}}}
65 \subsection{Method \code{clone()}}{
66 The objects of this class are cloneable with this method.
67 \subsection{Usage}{
68 \if{html}{\out{<div class="r">}}\preformatted{FilterInject$clone(deep = FALSE)}\if{html}{\out{</div>}}
69 }
70
71 \subsection{Arguments}{
72 \if{html}{\out{<div class="arguments">}}
73 \describe{
74 \item{\code{deep}}{Whether to make a deep clone.}
75 }
76 \if{html}{\out{</div>}}
77 }
78 }
79 }