Debian Codegraph @

man/Logger.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/Logger.R
3 \name{Logger}
4 \alias{Logger}
5 \alias{Loggers}
6 \title{Loggers}
7 \description{
8 A Logger produces a \link{LogEvent} that contains a log message along with
9 metadata (timestamp, calling function, ...) and dispatches it to one or
10 more \link{Appenders} which are responsible for the output (console, file, ...)
11 of the event. \strong{lgr} comes with a single pre-configured Logger called the
12 \verb{root Logger} that can be accessed via \verb{lgr$<...>}. Instantiation of new
13 Loggers is done with \code{\link[=get_logger]{get_logger()}}. It is advisable to instantiate a
14 separate Logger with a descriptive name for each package/script in which
15 you use \pkg{lgr}.
16 }
17 \note{
18 If you are a package developer you should define a new Logger for each
19 package, but you do not need to configure it. The user of the package
20 should decide how and where to output logging, usually by configuring the
21 root Logger (new Appenders added/removed, Layouts modified, etc...).
22 }
23 \examples{
24 # lgr::lgr is the root logger that is always available
25 lgr$info("Today is a good day")
26 lgr$fatal("This is a serious error")
27
28 # Loggers use sprintf() for string formatting by default
29 lgr$info("Today is \%s", Sys.Date() )
30
31 # If no unnamed `...` are present, msg is not passed through sprintf()
32 lgr$fatal("100\% bad") # so this works
33 lgr$fatal("\%s\%\% bad", 100) # if you use unnamed arguments, you must escape \%
34
35 # You can create new loggers with get_logger()
36 tf <- tempfile()
37 lg <- get_logger("mylogger")$set_appenders(AppenderFile$new(tf))
38
39 # The new logger passes the log message on to the appenders of its parent
40 # logger, which is by default the root logger. This is why the following
41 # writes not only the file 'tf', but also to the console.
42 lg$fatal("blubb")
43 readLines(tf)
44
45 # This logger's print() method depicts this relationship.
46 child <- get_logger("lg/child")
47 print(child)
48 print(child$name)
49
50 # use formatting strings and custom fields
51 tf2 <- tempfile()
52 lg$add_appender(AppenderFile$new(tf2, layout = LayoutJson$new()))
53 lg$info("Not all \%s support custom fields", "appenders", type = "test")
54 cat(readLines(tf), sep = "\n")
55 cat(readLines(tf2), sep = "\n")
56
57 # cleanup
58 unlink(c(tf, tf2))
59 lg$config(NULL) # reset logger config
60
61 # LoggerGlue
62 # You can also create a new logger that uses the awesome glue library for
63 # string formatting instead of sprintf
64
65 if (requireNamespace("glue")){
66
67 lg <- get_logger_glue("glue")
68 lg$fatal("blah ", "fizz is set to: {fizz}", foo = "bar", fizz = "buzz")
69 # prevent creation of custom fields with prefixing a dot
70 lg$fatal("blah ", "fizz is set to: {.fizz}", foo = "bar", .fizz = "buzz")
71
72 #' # completely reset 'glue' to an unconfigured vanilla Logger
73 get_logger("glue", reset = TRUE)
74
75 }
76
77
78 # Configuring a Logger
79 lg <- get_logger("test")
80 lg$config(NULL) # resets logger to unconfigured state
81
82 # With setters
83 lg$
84 set_threshold("error")$
85 set_propagate(FALSE)$
86 set_appenders(AppenderConsole$new(threshold = "info"))
87
88 lg$config(NULL)
89
90 # With a list
91 lg$config(list(
92 threshold = "error",
93 propagate = FALSE,
94 appenders = list(AppenderConsole$new(threshold = "info"))
95 ))
96
97 lg$config(NULL) # resets logger to unconfigured state
98
99 # Via YAML
100 cfg <- "
101 Logger:
102 threshold: error
103 propagate: false
104 appenders:
105 AppenderConsole:
106 threshold: info
107 "
108
109 lg$config(cfg)
110 lg$config(NULL)
111
112 ## ------------------------------------------------
113 ## Method `Logger$list_log`
114 ## ------------------------------------------------
115
116 lg <- get_logger("test")
117 lg$list_log(list(level = 400, msg = "example"))
118
119 ## ------------------------------------------------
120 ## Method `Logger$add_appender`
121 ## ------------------------------------------------
122
123 lg <- get_logger("test")
124 lg$add_appender(AppenderConsole$new(), name = "myconsole")
125 lg$appenders[[1]]
126 lg$appenders$myconsole
127 lg$remove_appender("myconsole")
128 lg$config(NULL) # reset config
129
130 ## ------------------------------------------------
131 ## Method `Logger$set_exception_handler`
132 ## ------------------------------------------------
133
134 lgr$info(stop("this produces a warning instead of an error"))
135 }
136 \seealso{
137 \href{https://glue.tidyverse.org/}{glue}
138
139 \code{\link[=get_logger]{get_logger()}}
140 }
141 \section{Super class}{
142 \code{\link[lgr:Filterable]{lgr::Filterable}} -> \code{Logger}
143 }
144 \section{Active bindings}{
145 \if{html}{\out{<div class="r6-active-bindings">}}
146 \describe{
147 \item{\code{name}}{A \code{character} scalar. The unique name of each logger,
148 which also includes the names of its ancestors (separated by \code{/}).}
149
150 \item{\code{threshold}}{\code{integer} scalar. The threshold of the \code{Logger}, or if it
151 \code{NULL} the threshold it inherits from its closest ancestor with a
152 non-\code{NULL} threshold}
153
154 \item{\code{propagate}}{A \code{TRUE} or \code{FALSE}. Should a Logger propagate events
155 to the Appenders of its ancestors?}
156
157 \item{\code{ancestry}}{A named \code{logical} vector of containing the propagate value
158 of each Logger upper the inheritance tree. The names are the names of
159 the appenders. \code{ancestry} is an S3 class with a custom
160 \code{format()}/\code{print()} method, so if you want to use the plain logical
161 vector use \code{unclass(lg$ancestry)}}
162
163 \item{\code{parent}}{a \code{Logger}. The direct ancestor of the \code{Logger}.}
164
165 \item{\code{last_event}}{The last LogEvent produced by the current Logger}
166
167 \item{\code{appenders}}{a \code{list} of all \link{Appenders} of the Logger}
168
169 \item{\code{inherited_appenders}}{A \code{list} of all appenders that the Logger
170 inherits from its ancestors}
171
172 \item{\code{exception_handler}}{a \code{function}. See \verb{$set_exception_handler} and
173 \verb{$handle_exception}}
174 }
175 \if{html}{\out{</div>}}
176 }
177 \section{Methods}{
178 \subsection{Public methods}{
179 \itemize{
180 \item \href{#method-Logger-new}{\code{Logger$new()}}
181 \item \href{#method-Logger-log}{\code{Logger$log()}}
182 \item \href{#method-Logger-fatal}{\code{Logger$fatal()}}
183 \item \href{#method-Logger-error}{\code{Logger$error()}}
184 \item \href{#method-Logger-warn}{\code{Logger$warn()}}
185 \item \href{#method-Logger-info}{\code{Logger$info()}}
186 \item \href{#method-Logger-debug}{\code{Logger$debug()}}
187 \item \href{#method-Logger-trace}{\code{Logger$trace()}}
188 \item \href{#method-Logger-list_log}{\code{Logger$list_log()}}
189 \item \href{#method-Logger-config}{\code{Logger$config()}}
190 \item \href{#method-Logger-add_appender}{\code{Logger$add_appender()}}
191 \item \href{#method-Logger-remove_appender}{\code{Logger$remove_appender()}}
192 \item \href{#method-Logger-handle_exception}{\code{Logger$handle_exception()}}
193 \item \href{#method-Logger-set_exception_handler}{\code{Logger$set_exception_handler()}}
194 \item \href{#method-Logger-set_propagate}{\code{Logger$set_propagate()}}
195 \item \href{#method-Logger-set_threshold}{\code{Logger$set_threshold()}}
196 \item \href{#method-Logger-set_appenders}{\code{Logger$set_appenders()}}
197 \item \href{#method-Logger-set_replace_empty}{\code{Logger$set_replace_empty()}}
198 \item \href{#method-Logger-spawn}{\code{Logger$spawn()}}
199 }
200 }
201 \if{html}{\out{
202 <details open><summary>Inherited methods</summary>
203 <ul>
204 <li><span class="pkg-link" data-pkg="lgr" data-topic="Filterable" data-id="add_filter"><a href='../../lgr/html/Filterable.html#method-Filterable-add_filter'><code>lgr::Filterable$add_filter()</code></a></span></li>
205 <li><span class="pkg-link" data-pkg="lgr" data-topic="Filterable" data-id="filter"><a href='../../lgr/html/Filterable.html#method-Filterable-filter'><code>lgr::Filterable$filter()</code></a></span></li>
206 <li><span class="pkg-link" data-pkg="lgr" data-topic="Filterable" data-id="remove_filter"><a href='../../lgr/html/Filterable.html#method-Filterable-remove_filter'><code>lgr::Filterable$remove_filter()</code></a></span></li>
207 <li><span class="pkg-link" data-pkg="lgr" data-topic="Filterable" data-id="set_filters"><a href='../../lgr/html/Filterable.html#method-Filterable-set_filters'><code>lgr::Filterable$set_filters()</code></a></span></li>
208 </ul>
209 </details>
210 }}
211 \if{html}{\out{<hr>}}
212 \if{html}{\out{<a id="method-Logger-new"></a>}}
213 \if{latex}{\out{\hypertarget{method-Logger-new}{}}}
214 \subsection{Method \code{new()}}{
215 \strong{Loggers should never be instantiated directly with \code{Logger$new()}} but
216 rather via \code{\link[=get_logger]{get_logger("name")}}. This way new Loggers are
217 registered in a global namespace which ensures uniqueness and
218 facilitates inheritance between Loggers. If \code{"name"} does not exist, a
219 new Logger with that name will be created, otherwise the function returns
220 a Reference to the existing Logger.
221
222 \code{name} is potentially a \code{"/"} separated hierarchical value like
223 \code{foo/bar/baz}. Loggers further down the hierarchy are descendants of the
224 loggers above and (by default) inherit \code{threshold} and \code{Appenders} from
225 their ancestors.
226 \subsection{Usage}{
227 \if{html}{\out{<div class="r">}}\preformatted{Logger$new(
228 name = "(unnamed logger)",
229 appenders = list(),
230 threshold = NULL,
231 filters = list(),
232 exception_handler = default_exception_handler,
233 propagate = TRUE,
234 replace_empty = "<NULL>"
235 )}\if{html}{\out{</div>}}
236 }
237
238 \subsection{Arguments}{
239 \if{html}{\out{<div class="arguments">}}
240 \describe{
241 \item{\code{name, appenders, threshold, filters, exception_handler, propagate}}{See section Active bindings.}
242 }
243 \if{html}{\out{</div>}}
244 }
245 }
246 \if{html}{\out{<hr>}}
247 \if{html}{\out{<a id="method-Logger-log"></a>}}
248 \if{latex}{\out{\hypertarget{method-Logger-log}{}}}
249 \subsection{Method \code{log()}}{
250 Log an event.
251
252 If \code{level} passes the Logger's \code{threshold} a new \link{LogEvent} with \code{level},
253 \code{msg}, \code{timestamp} and \code{caller} is created. If the new LogEvent also
254 passes the Loggers \link[=EventFilter]{Filters}, it is be dispatched to the
255 relevant \link{Appenders}.
256 \subsection{Usage}{
257 \if{html}{\out{<div class="r">}}\preformatted{Logger$log(level, msg, ..., timestamp = Sys.time(), caller = get_caller(-7))}\if{html}{\out{</div>}}
258 }
259
260 \subsection{Arguments}{
261 \if{html}{\out{<div class="arguments">}}
262 \describe{
263 \item{\code{level}}{a \code{character} or \code{integer} scalar. See \link{log_levels}.}
264
265 \item{\code{msg}}{\code{character}. A log message. If unnamed arguments are supplied
266 in \code{...}, \code{msg} is passed on to \code{\link[base:sprintf]{base::sprintf()}} (which means \code{"\%"} have
267 to be escaped), otherwise \code{msg} is left as-is.}
268
269 \item{\code{...}}{\emph{unnamed} arguments in \code{...} must be \code{character} scalars and
270 are passed to \code{\link[base:sprintf]{base::sprintf()}}. \emph{Named} arguments must have unique names
271 but can be arbitrary \R objects that are passed to \code{\link[=LogEvent]{LogEvent$new()}} and
272 will be turned into custom fields.}
273
274 \item{\code{timestamp}}{\link{POSIXct}. Timestamp of the event.}
275
276 \item{\code{caller}}{a \code{character} scalar. The name of the calling function.}
277 }
278 \if{html}{\out{</div>}}
279 }
280 }
281 \if{html}{\out{<hr>}}
282 \if{html}{\out{<a id="method-Logger-fatal"></a>}}
283 \if{latex}{\out{\hypertarget{method-Logger-fatal}{}}}
284 \subsection{Method \code{fatal()}}{
285 Log an Event fatal priority
286 \subsection{Usage}{
287 \if{html}{\out{<div class="r">}}\preformatted{Logger$fatal(msg, ..., caller = get_caller(-8L))}\if{html}{\out{</div>}}
288 }
289
290 \subsection{Arguments}{
291 \if{html}{\out{<div class="arguments">}}
292 \describe{
293 \item{\code{msg, ..., caller}}{see \verb{$log()}}
294 }
295 \if{html}{\out{</div>}}
296 }
297 }
298 \if{html}{\out{<hr>}}
299 \if{html}{\out{<a id="method-Logger-error"></a>}}
300 \if{latex}{\out{\hypertarget{method-Logger-error}{}}}
301 \subsection{Method \code{error()}}{
302 Log an Event error priority
303 \subsection{Usage}{
304 \if{html}{\out{<div class="r">}}\preformatted{Logger$error(msg, ..., caller = get_caller(-8L))}\if{html}{\out{</div>}}
305 }
306
307 \subsection{Arguments}{
308 \if{html}{\out{<div class="arguments">}}
309 \describe{
310 \item{\code{msg, ..., caller}}{see \verb{$log()}}
311 }
312 \if{html}{\out{</div>}}
313 }
314 }
315 \if{html}{\out{<hr>}}
316 \if{html}{\out{<a id="method-Logger-warn"></a>}}
317 \if{latex}{\out{\hypertarget{method-Logger-warn}{}}}
318 \subsection{Method \code{warn()}}{
319 Log an Event warn priority
320 \subsection{Usage}{
321 \if{html}{\out{<div class="r">}}\preformatted{Logger$warn(msg, ..., caller = get_caller(-8L))}\if{html}{\out{</div>}}
322 }
323
324 \subsection{Arguments}{
325 \if{html}{\out{<div class="arguments">}}
326 \describe{
327 \item{\code{msg, ..., caller}}{see \verb{$log()}}
328 }
329 \if{html}{\out{</div>}}
330 }
331 }
332 \if{html}{\out{<hr>}}
333 \if{html}{\out{<a id="method-Logger-info"></a>}}
334 \if{latex}{\out{\hypertarget{method-Logger-info}{}}}
335 \subsection{Method \code{info()}}{
336 Log an Event info priority
337 \subsection{Usage}{
338 \if{html}{\out{<div class="r">}}\preformatted{Logger$info(msg, ..., caller = get_caller(-8L))}\if{html}{\out{</div>}}
339 }
340
341 \subsection{Arguments}{
342 \if{html}{\out{<div class="arguments">}}
343 \describe{
344 \item{\code{msg, ..., caller}}{see \verb{$log()}}
345 }
346 \if{html}{\out{</div>}}
347 }
348 }
349 \if{html}{\out{<hr>}}
350 \if{html}{\out{<a id="method-Logger-debug"></a>}}
351 \if{latex}{\out{\hypertarget{method-Logger-debug}{}}}
352 \subsection{Method \code{debug()}}{
353 Log an Event debug priority
354 \subsection{Usage}{
355 \if{html}{\out{<div class="r">}}\preformatted{Logger$debug(msg, ..., caller = get_caller(-8L))}\if{html}{\out{</div>}}
356 }
357
358 \subsection{Arguments}{
359 \if{html}{\out{<div class="arguments">}}
360 \describe{
361 \item{\code{msg, ..., caller}}{see \verb{$log()}}
362 }
363 \if{html}{\out{</div>}}
364 }
365 }
366 \if{html}{\out{<hr>}}
367 \if{html}{\out{<a id="method-Logger-trace"></a>}}
368 \if{latex}{\out{\hypertarget{method-Logger-trace}{}}}
369 \subsection{Method \code{trace()}}{
370 Log an Event trace priority
371 \subsection{Usage}{
372 \if{html}{\out{<div class="r">}}\preformatted{Logger$trace(msg, ..., caller = get_caller(-8L))}\if{html}{\out{</div>}}
373 }
374
375 \subsection{Arguments}{
376 \if{html}{\out{<div class="arguments">}}
377 \describe{
378 \item{\code{msg, ..., caller}}{see \verb{$log()}}
379 }
380 \if{html}{\out{</div>}}
381 }
382 }
383 \if{html}{\out{<hr>}}
384 \if{html}{\out{<a id="method-Logger-list_log"></a>}}
385 \if{latex}{\out{\hypertarget{method-Logger-list_log}{}}}
386 \subsection{Method \code{list_log()}}{
387 \code{list_log()} is a shortcut for \code{do.call(Logger$log, x)}.
388 See \url{https://github.com/s-fleck/joblog} for an R package that
389 leverages this feature to create custom log event types for tracking
390 the status of cron jobs.
391 \subsection{Usage}{
392 \if{html}{\out{<div class="r">}}\preformatted{Logger$list_log(x)}\if{html}{\out{</div>}}
393 }
394
395 \subsection{Arguments}{
396 \if{html}{\out{<div class="arguments">}}
397 \describe{
398 \item{\code{x}}{a named \code{list} that must at least contain the named elements
399 \code{level} and \code{timestamp}}
400 }
401 \if{html}{\out{</div>}}
402 }
403 \subsection{Examples}{
404 \if{html}{\out{<div class="r example copy">}}
405 \preformatted{lg <- get_logger("test")
406 lg$list_log(list(level = 400, msg = "example"))
407 }
408 \if{html}{\out{</div>}}
409
410 }
411
412 }
413 \if{html}{\out{<hr>}}
414 \if{html}{\out{<a id="method-Logger-config"></a>}}
415 \if{latex}{\out{\hypertarget{method-Logger-config}{}}}
416 \subsection{Method \code{config()}}{
417 Load a Logger configuration.
418 \subsection{Usage}{
419 \if{html}{\out{<div class="r">}}\preformatted{Logger$config(cfg, file, text, list)}\if{html}{\out{</div>}}
420 }
421
422 \subsection{Arguments}{
423 \if{html}{\out{<div class="arguments">}}
424 \describe{
425 \item{\code{cfg}}{\itemize{
426 \item a special \code{list} object with any or all of the the following elements:
427 \code{appenders}, \code{threshold}, \code{filters}, \code{propagate}, \code{exception_handler},
428 \item the path to a \code{YAML}/\code{JSON} config file,
429 \item a \code{character} scalar containing \code{YAML/JSON},
430 \item \code{NULL} (to reset the logger config to the default/unconfigured state)
431 }}
432
433 \item{\code{file, text, list}}{can be used as an alternative to
434 \code{cfg} that enforces that the supplied argument is of the specified
435 type. See \link{logger_config} for details.}
436 }
437 \if{html}{\out{</div>}}
438 }
439 }
440 \if{html}{\out{<hr>}}
441 \if{html}{\out{<a id="method-Logger-add_appender"></a>}}
442 \if{latex}{\out{\hypertarget{method-Logger-add_appender}{}}}
443 \subsection{Method \code{add_appender()}}{
444 Add an Appender to the Logger
445 \subsection{Usage}{
446 \if{html}{\out{<div class="r">}}\preformatted{Logger$add_appender(appender, name = NULL)}\if{html}{\out{</div>}}
447 }
448
449 \subsection{Arguments}{
450 \if{html}{\out{<div class="arguments">}}
451 \describe{
452 \item{\code{appender}}{a single \link{Appender}}
453
454 \item{\code{name}}{a \code{character} scalar. Optional but recommended.}
455 }
456 \if{html}{\out{</div>}}
457 }
458 \subsection{Examples}{
459 \if{html}{\out{<div class="r example copy">}}
460 \preformatted{lg <- get_logger("test")
461 lg$add_appender(AppenderConsole$new(), name = "myconsole")
462 lg$appenders[[1]]
463 lg$appenders$myconsole
464 lg$remove_appender("myconsole")
465 lg$config(NULL) # reset config
466 }
467 \if{html}{\out{</div>}}
468
469 }
470
471 }
472 \if{html}{\out{<hr>}}
473 \if{html}{\out{<a id="method-Logger-remove_appender"></a>}}
474 \if{latex}{\out{\hypertarget{method-Logger-remove_appender}{}}}
475 \subsection{Method \code{remove_appender()}}{
476 remove an appender
477 \subsection{Usage}{
478 \if{html}{\out{<div class="r">}}\preformatted{Logger$remove_appender(pos)}\if{html}{\out{</div>}}
479 }
480
481 \subsection{Arguments}{
482 \if{html}{\out{<div class="arguments">}}
483 \describe{
484 \item{\code{pos}}{\code{integer} index or \code{character} name of the Appender(s) to
485 remove}
486 }
487 \if{html}{\out{</div>}}
488 }
489 }
490 \if{html}{\out{<hr>}}
491 \if{html}{\out{<a id="method-Logger-handle_exception"></a>}}
492 \if{latex}{\out{\hypertarget{method-Logger-handle_exception}{}}}
493 \subsection{Method \code{handle_exception()}}{
494 To prevent errors in the logging logic from crashing the whole script,
495 Loggers pass errors they encounter to an exception handler. The default
496 behaviour is to demote errors to \link{warnings}. See also
497 \code{set_exception_handler()}.
498 \subsection{Usage}{
499 \if{html}{\out{<div class="r">}}\preformatted{Logger$handle_exception(expr)}\if{html}{\out{</div>}}
500 }
501
502 \subsection{Arguments}{
503 \if{html}{\out{<div class="arguments">}}
504 \describe{
505 \item{\code{expr}}{expression to be evaluated.}
506 }
507 \if{html}{\out{</div>}}
508 }
509 }
510 \if{html}{\out{<hr>}}
511 \if{html}{\out{<a id="method-Logger-set_exception_handler"></a>}}
512 \if{latex}{\out{\hypertarget{method-Logger-set_exception_handler}{}}}
513 \subsection{Method \code{set_exception_handler()}}{
514 Set the exception handler of a logger
515 \subsection{Usage}{
516 \if{html}{\out{<div class="r">}}\preformatted{Logger$set_exception_handler(fun)}\if{html}{\out{</div>}}
517 }
518
519 \subsection{Arguments}{
520 \if{html}{\out{<div class="arguments">}}
521 \describe{
522 \item{\code{fun}}{a \code{function} with the single argument \code{e} (an error \link{condition})}
523 }
524 \if{html}{\out{</div>}}
525 }
526 \subsection{Examples}{
527 \if{html}{\out{<div class="r example copy">}}
528 \preformatted{lgr$info(stop("this produces a warning instead of an error"))
529 }
530 \if{html}{\out{</div>}}
531
532 }
533
534 }
535 \if{html}{\out{<hr>}}
536 \if{html}{\out{<a id="method-Logger-set_propagate"></a>}}
537 \if{latex}{\out{\hypertarget{method-Logger-set_propagate}{}}}
538 \subsection{Method \code{set_propagate()}}{
539 Should a Logger propagate events to the Appenders of its ancestors?
540 \subsection{Usage}{
541 \if{html}{\out{<div class="r">}}\preformatted{Logger$set_propagate(x)}\if{html}{\out{</div>}}
542 }
543
544 \subsection{Arguments}{
545 \if{html}{\out{<div class="arguments">}}
546 \describe{
547 \item{\code{x}}{\code{TRUE} or \code{FALSE}. Should \link{LogEvents} be passed on to the appenders
548 of the ancestral Loggers?}
549 }
550 \if{html}{\out{</div>}}
551 }
552 }
553 \if{html}{\out{<hr>}}
554 \if{html}{\out{<a id="method-Logger-set_threshold"></a>}}
555 \if{latex}{\out{\hypertarget{method-Logger-set_threshold}{}}}
556 \subsection{Method \code{set_threshold()}}{
557 Set the minimum log level of events that a Logger should process
558 \subsection{Usage}{
559 \if{html}{\out{<div class="r">}}\preformatted{Logger$set_threshold(level)}\if{html}{\out{</div>}}
560 }
561
562 \subsection{Arguments}{
563 \if{html}{\out{<div class="arguments">}}
564 \describe{
565 \item{\code{level}}{\code{character} or \code{integer} scalar. The minimum
566 \link[=log_levels]{log level} that triggers this Logger}
567 }
568 \if{html}{\out{</div>}}
569 }
570 }
571 \if{html}{\out{<hr>}}
572 \if{html}{\out{<a id="method-Logger-set_appenders"></a>}}
573 \if{latex}{\out{\hypertarget{method-Logger-set_appenders}{}}}
574 \subsection{Method \code{set_appenders()}}{
575 Set the Logger's Appenders
576 \subsection{Usage}{
577 \if{html}{\out{<div class="r">}}\preformatted{Logger$set_appenders(x)}\if{html}{\out{</div>}}
578 }
579
580 \subsection{Arguments}{
581 \if{html}{\out{<div class="arguments">}}
582 \describe{
583 \item{\code{x}}{single \link{Appender} or a \code{list} thereof. Appenders control the
584 output of a Logger. Be aware that a Logger also inherits the Appenders
585 of its ancestors (see \code{vignette("lgr", package = "lgr")} for more info
586 about Logger inheritance).}
587 }
588 \if{html}{\out{</div>}}
589 }
590 }
591 \if{html}{\out{<hr>}}
592 \if{html}{\out{<a id="method-Logger-set_replace_empty"></a>}}
593 \if{latex}{\out{\hypertarget{method-Logger-set_replace_empty}{}}}
594 \subsection{Method \code{set_replace_empty()}}{
595 Set the replacement for empty values (\code{NULL} or empty
596 vectors)
597 \subsection{Usage}{
598 \if{html}{\out{<div class="r">}}\preformatted{Logger$set_replace_empty(x)}\if{html}{\out{</div>}}
599 }
600
601 \subsection{Arguments}{
602 \if{html}{\out{<div class="arguments">}}
603 \describe{
604 \item{\code{x}}{should be a \code{character} vector, but other types of values are
605 supported. use wisely.}
606 }
607 \if{html}{\out{</div>}}
608 }
609 }
610 \if{html}{\out{<hr>}}
611 \if{html}{\out{<a id="method-Logger-spawn"></a>}}
612 \if{latex}{\out{\hypertarget{method-Logger-spawn}{}}}
613 \subsection{Method \code{spawn()}}{
614 Spawn a child Logger.
615 This is very similar to using \code{\link[=get_logger]{get_logger()}}, but
616 can be useful in some cases where Loggers are created programmatically
617 \subsection{Usage}{
618 \if{html}{\out{<div class="r">}}\preformatted{Logger$spawn(name)}\if{html}{\out{</div>}}
619 }
620
621 \subsection{Arguments}{
622 \if{html}{\out{<div class="arguments">}}
623 \describe{
624 \item{\code{name}}{\code{character} vector. Name of the child logger
625 \code{get_logger("foo/bar")$spawn("baz")} is equivalent
626 to \code{get_logger("foo/bar/baz")}}
627 }
628 \if{html}{\out{</div>}}
629 }
630 }
631 }