|
1 | | -#' Create logger configs |
| 1 | +#' Logger Configuration Objects |
2 | 2 | #' |
3 | | -#' Coerce any supported \R object to a `logger_config` object. You usually do |
4 | | -#' not have to call this function directly, as it is automatically |
5 | | -#' invoked by the `config()` method of Loggers (see examples) |
| 3 | +#' `logger_config()` and `basic_config()` can be used to directly create |
| 4 | +#' objects that can be passed to the `$config()` method of Loggers. |
6 | 5 | #' |
7 | | -#' @param x any \R object. Especially: |
8 | | -#' * A `character` scalar. This can either be the path to a |
9 | | -#' [YAML][https://yaml.org/] file, or directly valid YAML |
10 | | -#' * a list containing the elements `appenders`, `threshold`, `exception_handler`, |
11 | | -#' `propagate` and `filters`. See the section *Fields* in [Logger] for |
12 | | -#' details. |
13 | | -#' * a Logger object, to clone its configuration. |
14 | | -#' |
15 | | -#' |
16 | | -#' @return a logger_config object |
17 | | -#' @export |
18 | | -#' |
19 | | -#' @examples |
20 | | -#' cfg <- " |
21 | | -#' Logger: |
22 | | -#' name: test/blubb |
23 | | -#' threshold: info |
24 | | -#' propagate: false |
25 | | -#' appenders: |
26 | | -#' AppenderFile: |
27 | | -#' file: /tmp/blah.txt |
28 | | -#' " |
29 | | -#' lg$config(as_logger_config(cfg)) |
30 | | -#' # but you can just do the following directly |
31 | | -#' lg <- get_logger("test") |
32 | | -#' lg$config(cfg) |
33 | | -#' |
34 | | -as_logger_config <- function(x){ |
35 | | - UseMethod("as_logger_config") |
36 | | -} |
37 | | - |
38 | | - |
39 | | - |
40 | | - |
41 | | -#' Create a Logger configuration object |
42 | | -#' |
43 | | -#' @param appenders |
44 | | -#' @param threshold |
45 | | -#' @param filters |
46 | | -#' @param exception_handler |
47 | | -#' @param propagate |
| 6 | +#' @param appenders,threshold,filters,exception_handler,propagate see [Logger] |
48 | 7 | #' |
49 | 8 | #' @return a `list` with subclass `"logger_config"` |
50 | 9 | #' @export |
@@ -81,6 +40,42 @@ logger_config <- function( |
81 | 40 |
|
82 | 41 |
|
83 | 42 |
|
| 43 | +#' `as_logger_config()` coerces any supported \R object to a `logger_config` |
| 44 | +#' object. You usually do not have to call this function directly, as it is |
| 45 | +#' automatically invoked by the `config()` method of Loggers (see examples) |
| 46 | +#' |
| 47 | +#' @param x any \R object. Especially: |
| 48 | +#' * A `character` scalar. This can either be the path to a |
| 49 | +#' [YAML][https://yaml.org/] file, or directly valid YAML |
| 50 | +#' * a list containing the elements `appenders`, `threshold`, `exception_handler`, |
| 51 | +#' `propagate` and `filters`. See the section *Fields* in [Logger] for |
| 52 | +#' details. |
| 53 | +#' * a Logger object, to clone its configuration. |
| 54 | +#' |
| 55 | +#' @rdname logger_config |
| 56 | +#' @return a logger_config object |
| 57 | +#' @export |
| 58 | +#' |
| 59 | +#' @examples |
| 60 | +#' cfg <- " |
| 61 | +#' Logger: |
| 62 | +#' name: test/blubb |
| 63 | +#' threshold: info |
| 64 | +#' propagate: false |
| 65 | +#' appenders: |
| 66 | +#' AppenderFile: |
| 67 | +#' file: /tmp/blah.txt |
| 68 | +#' " |
| 69 | +#' lg$config(as_logger_config(cfg)) |
| 70 | +#' # but you can just do the following directly |
| 71 | +#' lg <- get_logger("test") |
| 72 | +#' lg$config(cfg) |
| 73 | +#' |
| 74 | +as_logger_config <- function(x){ |
| 75 | + UseMethod("as_logger_config") |
| 76 | +} |
| 77 | + |
| 78 | + |
84 | 79 |
|
85 | 80 |
|
86 | 81 | #' @rdname as_logger_config |
@@ -239,8 +234,20 @@ standardize_filters_list <- function(x){ |
239 | 234 |
|
240 | 235 |
|
241 | 236 |
|
| 237 | +#' Title |
| 238 | +#' @rdname logger_config |
| 239 | +#' @param file `character` scalar. |
| 240 | +#' @param fmt |
| 241 | +#' @param fmt_timestamp |
| 242 | +#' @param threshold |
| 243 | +#' @param appenders |
| 244 | +#' |
| 245 | +#' @return |
| 246 | +#' @export |
| 247 | +#' |
| 248 | +#' @examples |
242 | 249 | basic_config = function( |
243 | | - filename, |
| 250 | + file, |
244 | 251 | fmt, |
245 | 252 | fmt_timestamp, |
246 | 253 | threshold, |
|
0 commit comments