From 9ea0d8196348010f417ec4f6ea6f54cf3ff2ad6c Mon Sep 17 00:00:00 2001 From: Stefan Fleck Date: Tue, 20 Aug 2019 11:00:16 +0200 Subject: [PATCH] prep for release --- R/basic_config.R | 2 +- cran-comments.md | 6 +- docs/articles/lgr.html | 128 +++++++++--------- docs/index.html | 18 +-- docs/reference/AppenderConsole.html | 4 +- docs/reference/AppenderDt.html | 18 +-- docs/reference/AppenderFile.html | 4 +- docs/reference/AppenderJson.html | 8 +- docs/reference/AppenderSyslog.html | 2 +- docs/reference/EventFilter.html | 4 +- docs/reference/LayoutFormat.html | 2 +- docs/reference/LayoutGlue.html | 4 +- docs/reference/LayoutJson.html | 2 +- docs/reference/LogEvent.html | 6 +- docs/reference/Logger.html | 16 +-- docs/reference/as.data.frame.LogEvent.html | 8 +- docs/reference/basic_config.html | 14 +- docs/reference/default_exception_handler.html | 2 +- docs/reference/get_logger.html | 8 +- docs/reference/print.LogEvent.html | 6 +- docs/reference/simple_logging.html | 16 +-- docs/reference/suspend_logging.html | 6 +- docs/reference/with_log_level.html | 8 +- inst/WORDLIST | 4 + man/basic_config.Rd | 2 +- 25 files changed, 153 insertions(+), 145 deletions(-) diff --git a/R/basic_config.R b/R/basic_config.R index 901b99f9..70a333c2 100644 --- a/R/basic_config.R +++ b/R/basic_config.R @@ -2,7 +2,7 @@ #' #' A quick and easy way to configure the root logger. This is less powerful #' then using [`lgr$config()` or `lgr$set_*()`][Logger], but reduces the -#' most common configrations to a single line of code. +#' most common configurations to a single line of code. #' #' @param file `character` scalar: If not `NULL` a [AppenderFile] will be #' created that logs to this file. If the filename ends in `.jsonl`, the diff --git a/cran-comments.md b/cran-comments.md index d69a9113..82d5add5 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -10,4 +10,8 @@ 0 errors | 0 warnings | 0 notes -adds appender that can write to syslog +Adds appender that can write to syslog. This introduces an optional dependency +on the linux-only rsyslog package, so checks fail on windows if suggests are +forced. Running the tests/examples of this package will write a few lines to +the syslog on linux systems, if this is an undesired side effect I can disable +the tests. diff --git a/docs/articles/lgr.html b/docs/articles/lgr.html index 7bed1005..5403736a 100644 --- a/docs/articles/lgr.html +++ b/docs/articles/lgr.html @@ -92,10 +92,10 @@

Logging to the console

# the root logger is called "lgr"
 lgr$info("Vampire stories are generally located in Styria.")
-#> INFO  [10:58:38.648] Vampire stories are generally located in Styria.
+#> INFO [15:05:39.627] Vampire stories are generally located in Styria.

You can use formatting strings that are passed on to sprintf() in lgr.

lgr$error("Vampires generally arrive in carriages drawn by %i black horses.", 2)
-#> ERROR [10:58:38.691] Vampires generally arrive in carriages drawn by 2 black horses.
+#> ERROR [15:05:39.672] Vampires generally arrive in carriages drawn by 2 black horses.

@@ -104,17 +104,17 @@

+#> [1] "INFO [2019-08-20 15:05:39.698] You must think I am joking"

The various Appenders available in lgr are R6 classes. To instantiate an object of that class (i.e. create a new appender) you have to use the $new() function as in the example above. Whenever you see something in lgr that IsNamedLikeThis, you can be sure that it is such an R6 class.

If you look at the output, you see that the timestamp format of the file appender is slightly different to the timestamp format of the console Appender. Formatting is handled by Layouts, and each Appender has exactly one:

lgr$appenders$file$set_layout(LayoutFormat$new(timestamp_fmt = "%B %d %T"))
 lgr$info("No, I am quite serious")
-#> INFO  [10:58:38.720] No, I am quite serious
+#> INFO  [15:05:39.711] No, I am quite serious
 readLines(tf)
-#> [1] "INFO  [2019-08-20 10:58:38.710] You must think I am joking"
-#> [2] "INFO  [August 20 10:58:38] No, I am quite serious"
+#> [1] "INFO  [2019-08-20 15:05:39.698] You must think I am joking"
+#> [2] "INFO  [August 20 15:05:39] No, I am quite serious"
 
 #cleanup
 unlink(tf)
@@ -130,25 +130,25 @@

# setup a JSON appender lgr$add_appender(AppenderJson$new(tf), name = "json") lgr$info("We lived in Styria") -#> INFO [10:58:38.739] We lived in Styria +#> INFO [15:05:39.729] We lived in Styria

JSON is still somewhat human readable

+#> {"level":400,"timestamp":"2019-08-20 15:05:39","logger":"root","caller":"eval","msg":"We lived in Styria"}

and easy for machines to parse

+#> 1 400 2019-08-20 15:05:39 root eval We lived in Styria

Many Appenders provide either a $show() method and a $data active binding convenience, and so you do not have to call readLines() & co manually.

+#> 1 400 2019-08-20 15:05:39 root eval We lived in Styria

Please note that under the hood, AppenderJson is just an AppenderFile with LayoutJson. The only difference is AppenderJson provides a $data() method while AppenderFile does not.

@@ -157,13 +157,13 @@

Unlike many others Loggers for R, lgr treats a LogEvent as a unit of data, not just a message with a timestamp. A log event can contain arbitrary data, though not all Appenders can handle that well. The JSON appender we added above is particularly good at handling most R objects.

@@ -286,15 +286,15 @@

LogEvents: The atomic unit of logging

LogEvents are objects that store all information collected by the Logger. They are passed on to Appenders that output them, but Appenders usually don’t utilize all the information present in a log event. The last event produced by a Logger is stored in its last_event field.

lgr$info("Vampire stories are generally located in Styria")
-#> INFO  [10:58:39.011] Vampire stories are generally located in Styria
+#> INFO  [15:05:40.021] Vampire stories are generally located in Styria
 lgr$last_event  # a summary output of the event
-#> INFO  [2019-08-20 10:58:39] Vampire stories are generally located in Styria
+#> INFO  [2019-08-20 15:05:40] Vampire stories are generally located in Styria
 lgr$last_event$values  # all values stored in the event as a list
 #> $level
 #> [1] 400
 #> 
 #> $timestamp
-#> [1] "2019-08-20 10:58:39 CEST"
+#> [1] "2019-08-20 15:05:40 CEST"
 #> 
 #> $logger
 #> [1] "root"
@@ -308,16 +308,16 @@ 

You should consider making use of custom fields liberally and using output formats that support them (such as JSON), rather than producing elaborately formatted but hard to parse log messages. If you ever want to analyse your log data, you will thank me for this tip.

@@ -335,7 +335,7 @@

lgr$info("is it a plane?") lgr$info("no! is it a bird?") -#> INFO [10:58:39.047] no! is it a bird? +#> INFO [15:05:40.057] no! is it a bird? # since this is not a very useful filter, we better remove it again lgr$set_filters(NULL)

@@ -356,12 +356,12 @@

lgr$appenders$console$set_threshold("info") lgr$appenders$file$set_threshold(NA) lgr$info("Another informational message") -#> INFO [10:58:39.065] Another informational message +#> INFO [15:05:40.084] Another informational message lgr$debug("A debug message not shown by the console appender") readLines(tf) -#> [1] "INFO [2019-08-20 10:58:39.065] Another informational message" -#> [2] "DEBUG [2019-08-20 10:58:39.067] A debug message not shown by the console appender" +#> [1] "INFO [2019-08-20 15:05:40.084] Another informational message" +#> [2] "DEBUG [2019-08-20 15:05:40.088] A debug message not shown by the console appender" # Remove the appender again lgr$remove_appender("file") @@ -403,13 +403,13 @@

"pastes together unnamed arguments ", "and evaluates arbitray expressions inside braces {Sys.Date()}" ) -#> INFO [10:58:39.112] glue automatically pastes together unnamed arguments and evaluates arbitray expressions inside braces 2019-08-20 +#> INFO [15:05:40.143] glue automatically pastes together unnamed arguments and evaluates arbitray expressions inside braces 2019-08-20

Glue lets you define temporary variables inside the glue() call. As with the normal Logger, named arguments get turned into custom fields.

+#> INFO [15:05:40.176] For more info on glue see https://glue.tidyverse.org/ {website: https://glue.tidyverse.org/}

You can suppress this behaviour by making named argument start with a ".".

+#> INFO [15:05:40.184] Glue is available from https://CRAN.R-project.org/package=glue +#> INFO (400) [15:05:40.254] eval(): !! A more involved custom format !!

If this is not enough for you, you can use LayoutGlue based on the awesome glue package. The syntax is a bit more verbose, and AppenderGlue is a bit less performant than AppenderFormat, but the possibilities are endless.

#>   level           timestamp logger caller             msg  field numbers
-#> 1   400 2019-08-20 10:58:39   test   eval JSON naturally  custom    NULL
-#> 2   400 2019-08-20 10:58:39   test   eval supports custom   <NA> 1, 2, 3
-#> 3   400 2019-08-20 10:58:39   test   eval      log fields   <NA>    NULL
+#> 1   400 2019-08-20 15:05:40   test   eval JSON naturally  custom    NULL
+#> 2   400 2019-08-20 15:05:40   test   eval supports custom   <NA> 1, 2, 3
+#> 3   400 2019-08-20 15:05:40   test   eval      log fields   <NA>    NULL
 #>    use
 #> 1 <NA>
 #> 2 <NA>
@@ -527,9 +527,9 @@ 

-
#> {"level":400,"timestamp":"2019-08-20 10:58:39","logger":"test","caller":"eval","msg":"JSON naturally ","field":"custom"}
-#> {"level":400,"timestamp":"2019-08-20 10:58:39","logger":"test","caller":"eval","msg":"supports custom","numbers":[1,2,3]}
-#> {"level":400,"timestamp":"2019-08-20 10:58:39","logger":"test","caller":"eval","msg":"log fields","use":"JSON"}
+
#> {"level":400,"timestamp":"2019-08-20 15:05:40","logger":"test","caller":"eval","msg":"JSON naturally ","field":"custom"}
+#> {"level":400,"timestamp":"2019-08-20 15:05:40","logger":"test","caller":"eval","msg":"supports custom","numbers":[1,2,3]}
+#> {"level":400,"timestamp":"2019-08-20 15:05:40","logger":"test","caller":"eval","msg":"log fields","use":"JSON"}
# cleanup
 lg$config(NULL)
 #> <Logger> [all] test
@@ -558,17 +558,17 @@ 

# display info on the backups of tf lg$appenders$rotating$backups #> path name sfx ext size -#> 1 /tmp/RtmpFwi8NS/file1f9845d36ba6.1.log file1f9845d36ba6 1 log 10608 -#> 2 /tmp/RtmpFwi8NS/file1f9845d36ba6.2.log file1f9845d36ba6 2 log 10608 -#> 3 /tmp/RtmpFwi8NS/file1f9845d36ba6.3.log file1f9845d36ba6 3 log 10608 -#> 4 /tmp/RtmpFwi8NS/file1f9845d36ba6.4.log file1f9845d36ba6 4 log 10608 -#> 5 /tmp/RtmpFwi8NS/file1f9845d36ba6.5.log file1f9845d36ba6 5 log 10608 +#> 1 /tmp/RtmpWQn7ry/file34b5325c3d3b.1.log file34b5325c3d3b 1 log 10608 +#> 2 /tmp/RtmpWQn7ry/file34b5325c3d3b.2.log file34b5325c3d3b 2 log 10608 +#> 3 /tmp/RtmpWQn7ry/file34b5325c3d3b.3.log file34b5325c3d3b 3 log 10608 +#> 4 /tmp/RtmpWQn7ry/file34b5325c3d3b.4.log file34b5325c3d3b 4 log 10608 +#> 5 /tmp/RtmpWQn7ry/file34b5325c3d3b.5.log file34b5325c3d3b 5 log 10608 #> isdir mode mtime ctime atime -#> 1 FALSE 664 2019-08-20 10:58:39 2019-08-20 10:58:39 2019-08-20 10:58:39 -#> 2 FALSE 664 2019-08-20 10:58:39 2019-08-20 10:58:39 2019-08-20 10:58:39 -#> 3 FALSE 664 2019-08-20 10:58:39 2019-08-20 10:58:39 2019-08-20 10:58:39 -#> 4 FALSE 664 2019-08-20 10:58:39 2019-08-20 10:58:39 2019-08-20 10:58:39 -#> 5 FALSE 664 2019-08-20 10:58:39 2019-08-20 10:58:39 2019-08-20 10:58:39 +#> 1 FALSE 664 2019-08-20 15:05:40 2019-08-20 15:05:40 2019-08-20 15:05:40 +#> 2 FALSE 664 2019-08-20 15:05:40 2019-08-20 15:05:40 2019-08-20 15:05:40 +#> 3 FALSE 664 2019-08-20 15:05:40 2019-08-20 15:05:40 2019-08-20 15:05:40 +#> 4 FALSE 664 2019-08-20 15:05:40 2019-08-20 15:05:40 2019-08-20 15:05:40 +#> 5 FALSE 664 2019-08-20 15:05:40 2019-08-20 15:05:40 2019-08-20 15:05:40 #> uid gid uname grname index #> 1 1000 1000 hoelk hoelk 1 #> 2 1000 1000 hoelk hoelk 2 @@ -599,14 +599,14 @@

#> <Logger> [all] mypackage #> #> appenders: -#> [[1]]: <AppenderFile> [all] -> /tmp/RtmpFwi8NS/file1f981922ddee +#> [[1]]: <AppenderFile> [all] -> /tmp/RtmpWQn7ry/file34b53c5a2647 #> #> inherited appenders: #> console: <AppenderConsole> [info] -> console

This tells us that lg logs all events of at least level info. It does have a single (unnamed) Appender that logs to a temporary file, and dispatches all LogEvents it creates to the Appenders of the root Logger (ignoring the threshold and filters of the root Logger, but not of its Appenders).

We can use lg$fatal(), lg$info(), etc.. to log messages with this Logger:

+#> INFO [15:05:40.780] A test message for lg

If we do not want lg to dispatch to the root Logger, we can set propagate to FALSE.

When we take a look at the Logger again, we now see that it does not inherit any Appenders anymore

@@ -614,7 +614,7 @@

#> <Logger> [all] mypackage #> #> appenders: -#> [[1]]: <AppenderFile> [all] -> /tmp/RtmpFwi8NS/file1f981922ddee +#> [[1]]: <AppenderFile> [all] -> /tmp/RtmpWQn7ry/file34b53c5a2647

Consequently, lg no longer outputs log messages to he console

+#> DEBUG [15:05:40.906] April +#> DEBUG [15:05:40.907] May +#> DEBUG [15:05:40.907] June +#> DEBUG [15:05:40.907] July +#> DEBUG [15:05:40.907] August +#> ERROR [15:05:40.909] But the days grow short when you reach September +#> INFO [2019-08-20 15:05:41] Logging to databases uses a buffer +#> INFO [2019-08-20 15:05:41] As the buffer size is 2, no insert took place till now +#> INFO [2019-08-20 15:05:41] Now as the buffer is rotated, all events are output to the db

@@ -716,9 +716,9 @@

} analyze()

The result is the same in both cases:

-
#> INFO  [10:58:40.091] cleaning data {dataset_id: dataset1}
-#> INFO  [10:58:40.092] processing data {dataset_id: dataset1}
-#> INFO  [10:58:40.093] outputing data {dataset_id: dataset1}
+
#> INFO  [15:05:41.199] cleaning data {dataset_id: dataset1}
+#> INFO  [15:05:41.201] processing data {dataset_id: dataset1}
+#> INFO  [15:05:41.201] outputing data {dataset_id: dataset1}

You can use with_log_level() and FilterForceLevel in a similar fashion to modify the log level of events conveniently.

diff --git a/docs/index.html b/docs/index.html index 145211de..9c57238d 100644 --- a/docs/index.html +++ b/docs/index.html @@ -111,13 +111,13 @@

Usage

To log an event with with lgr we call lgr$<logging function>(). Unnamed arguments to the logging function are interpreted by sprintf(). For a way to create loggers that glue instead please refer to the vignette.

By passing a named argument to info(), warn(), and co you can log not only text but arbitrary R objects. Not all appenders handle such custom fields perfectly, but JSON does. This way you can create logfiles that are machine as well as (somewhat) human readable.

+#> {"level":400,"timestamp":"2019-08-20 15:05:15","logger":"root","caller":"eval","msg":"cars has 50 rows"} +#> {"level":400,"timestamp":"2019-08-20 15:05:15","logger":"root","caller":"eval","msg":"loading cars","rows":50,"cols":2}

For more examples please see the package vignette and documentation

diff --git a/docs/reference/AppenderConsole.html b/docs/reference/AppenderConsole.html index 0becdd74..01a86363 100644 --- a/docs/reference/AppenderConsole.html +++ b/docs/reference/AppenderConsole.html @@ -230,8 +230,8 @@

Examp layout = LayoutFormat$new("[%t] %c(): [%n] %m", colors = getOption("lgr.colors")))) # Will output the message twice because we attached two console appenders -lg$warn("A test message")

#> WARN [10:58:20.791] A test message -#> [2019-08-20 10:58:20.791] eval(): [300] A test message
lg$config(NULL) # reset config
#> <Logger> [info] test +lg$warn("A test message")
#> WARN [15:05:22.475] A test message +#> [2019-08-20 15:05:22.475] eval(): [300] A test message
lg$config(NULL) # reset config
#> <Logger> [info] test #> #> inherited appenders: #> console: <AppenderConsole> [all] -> console
diff --git a/docs/reference/AppenderDt.html b/docs/reference/AppenderDt.html index bcc2230d..fbb9c11a 100644 --- a/docs/reference/AppenderDt.html +++ b/docs/reference/AppenderDt.html @@ -295,20 +295,20 @@

Examp # Displaying the log lg$appenders$memory$data
#> level timestamp logger caller msg -#> 1 500 2019-08-20 10:58:21 test eval test -#> 2 200 2019-08-20 10:58:21 test eval test
lg$appenders$memory$show()
#> DEBUG [10:58:21] test -#> ERROR [10:58:21] test
show_log(target = lg$appenders$memory)
#> DEBUG [10:58:21] test -#> ERROR [10:58:21] test
+#> 1 500 2019-08-20 15:05:23 test eval test +#> 2 200 2019-08-20 15:05:23 test eval test
lg$appenders$memory$show()
#> DEBUG [15:05:23] test +#> ERROR [15:05:23] test
show_log(target = lg$appenders$memory)
#> DEBUG [15:05:23] test +#> ERROR [15:05:23] test
# If you pass a Logger to show_log(), it looks for the first AppenderDt # that it can find. -show_log(target = lg)
#> DEBUG [10:58:21] test -#> ERROR [10:58:21] test
+show_log(target = lg)
#> DEBUG [15:05:23] test +#> ERROR [15:05:23] test
# Custom fields are stored in the list column .custom by default lg$info("the iris data frame", caps = LETTERS[1:5]) lg$appenders$memory$data
#> level timestamp logger caller msg caps -#> 1 500 2019-08-20 10:58:21 test eval test NULL -#> 2 200 2019-08-20 10:58:21 test eval test NULL -#> 3 400 2019-08-20 10:58:21 test eval the iris data frame A, B, C, D, E
lg$appenders$memory$data$.custom[[3]]$caps
#> NULL
lg$config(NULL)
#> <Logger> [info] test +#> 1 500 2019-08-20 15:05:23 test eval test NULL +#> 2 200 2019-08-20 15:05:23 test eval test NULL +#> 3 400 2019-08-20 15:05:23 test eval the iris data frame A, B, C, D, E
lg$appenders$memory$data$.custom[[3]]$caps
#> NULL
lg$config(NULL)
#> <Logger> [info] test #> #> inherited appenders: #> console: <AppenderConsole> [all] -> console
diff --git a/docs/reference/AppenderFile.html b/docs/reference/AppenderFile.html index 710314da..23aa9421 100644 --- a/docs/reference/AppenderFile.html +++ b/docs/reference/AppenderFile.html @@ -243,8 +243,8 @@

Examp AppenderFile$new(json, layout = LayoutJson$new()), "json" ) -lg$info("A test message")
#> INFO [10:58:22.586] A test message
-readLines(default)
#> [1] "INFO [2019-08-20 10:58:22.586] A test message"
readLines(fancy)
#> [1] "[2019-08-20 10:58:22.586] eval(): INFO A test message"
readLines(json)
#> [1] "{\"level\":400,\"timestamp\":\"2019-08-20 10:58:22\",\"logger\":\"test\",\"caller\":\"eval\",\"msg\":\"A test message\"}"
+lg$info("A test message")
#> INFO [15:05:24.118] A test message
+readLines(default)
#> [1] "INFO [2019-08-20 15:05:24.118] A test message"
readLines(fancy)
#> [1] "[2019-08-20 15:05:24.118] eval(): INFO A test message"
readLines(json)
#> [1] "{\"level\":400,\"timestamp\":\"2019-08-20 15:05:24\",\"logger\":\"test\",\"caller\":\"eval\",\"msg\":\"A test message\"}"
# cleanup lg$config(NULL)
#> <Logger> [info] test #> diff --git a/docs/reference/AppenderJson.html b/docs/reference/AppenderJson.html index 279e2236..e9dbb1ec 100644 --- a/docs/reference/AppenderJson.html +++ b/docs/reference/AppenderJson.html @@ -278,10 +278,10 @@

Examp lg$info("A test message") lg$info("A test message %s strings", "with format strings", and = "custom_fields") -lg$appenders[[1]]$show()

#> {"level":400,"timestamp":"2019-08-20 10:58:23","logger":"test","caller":"eval","msg":"A test message"} -#> {"level":400,"timestamp":"2019-08-20 10:58:23","logger":"test","caller":"eval","msg":"A test message with format strings strings","and":"custom_fields"}
lg$appenders[[1]]$data
#> level timestamp logger caller -#> 1 400 2019-08-20 10:58:23 test eval -#> 2 400 2019-08-20 10:58:23 test eval +lg$appenders[[1]]$show()
#> {"level":400,"timestamp":"2019-08-20 15:05:25","logger":"test","caller":"eval","msg":"A test message"} +#> {"level":400,"timestamp":"2019-08-20 15:05:25","logger":"test","caller":"eval","msg":"A test message with format strings strings","and":"custom_fields"}
lg$appenders[[1]]$data
#> level timestamp logger caller +#> 1 400 2019-08-20 15:05:25 test eval +#> 2 400 2019-08-20 15:05:25 test eval #> msg and #> 1 A test message <NA> #> 2 A test message with format strings strings custom_fields
diff --git a/docs/reference/AppenderSyslog.html b/docs/reference/AppenderSyslog.html index 284a6d66..68164896 100644 --- a/docs/reference/AppenderSyslog.html +++ b/docs/reference/AppenderSyslog.html @@ -246,7 +246,7 @@

Examp } invisible(lg$config(NULL)) # cleanup -}

#> INFO [10:58:25.151] A test message
+}
#> INFO [15:05:26.543] A test message
#> INFO [10:58:25.721] an error {type: analysis}
lg$error("an error")
#> ERROR [10:58:25.743] an error
lg$config(NULL) # reset config
#> <Logger> [info] test +analyse()
#> INFO [15:05:27.133] an error {type: analysis}
lg$error("an error")
#> ERROR [15:05:27.147] an error
lg$config(NULL) # reset config
#> <Logger> [info] test #> #> inherited appenders: #> console: <AppenderConsole> [all] -> console
@@ -185,7 +185,7 @@

Examp lg$add_filter(f) lg$fatal("test")

#> via event$.logger: 400 #> via .obj(): 400 -#> FATAL [10:58:25.755] test
lg$config(NULL)
#> <Logger> [info] test +#> FATAL [15:05:27.166] test
lg$config(NULL)
#> <Logger> [info] test #> #> inherited appenders: #> console: <AppenderConsole> [all] -> console
diff --git a/docs/reference/LayoutFormat.html b/docs/reference/LayoutFormat.html index 6e4ac2e9..1ed113f8 100644 --- a/docs/reference/LayoutFormat.html +++ b/docs/reference/LayoutFormat.html @@ -217,7 +217,7 @@

Examp msg = "a test message" ) lo <- LayoutFormat$new() -lo$format_event(event)
#> [1] "ERROR [2019-08-20 10:58:26.345] a test message"
+lo$format_event(event)
#> [1] "ERROR [2019-08-20 15:05:27.742] a test message"
#> FATAL [2019-08-20 10:58:26] msg
+lg$fatal("test")
#> FATAL [2019-08-20 15:05:28] msg
# All fields of the LogEvent are available, even custom ones lg$appenders[[1]]$layout$set_fmt( "{logger$name} {level_name}({level}) {caller}: {toupper(msg)} {{custom: {custom}}}" ) -lg$fatal("test", custom = "foobar")
#> Warning: [2019-08-20 10:58:26.695] An error occurred during logging: Error in logger$name: $ operator is invalid for atomic vectors
lg$config(NULL) # reset logger config
#> <Logger> [info] test +lg$fatal("test", custom = "foobar")
#> Warning: [2019-08-20 15:05:28.172] An error occurred during logging: Error in logger$name: $ operator is invalid for atomic vectors
lg$config(NULL) # reset logger config
#> <Logger> [info] test #> #> inherited appenders: #> console: <AppenderConsole> [all] -> console
diff --git a/docs/reference/LayoutJson.html b/docs/reference/LayoutJson.html index f0ae9209..0b7b99e5 100644 --- a/docs/reference/LayoutJson.html +++ b/docs/reference/LayoutJson.html @@ -186,7 +186,7 @@

Examp # Default settings show all event fals lo <- LayoutJson$new() -lo$format_event(event)

#> {"level":200,"timestamp":"2019-08-20 10:58:26","logger":"dummy logger","caller":null,"msg":"a test message","custom_field":"LayoutJson can handle arbitrary fields"}
+lo$format_event(event)
#> {"level":200,"timestamp":"2019-08-20 15:05:28","logger":"dummy logger","caller":null,"msg":"a test message","custom_field":"LayoutJson can handle arbitrary fields"}
#> FATAL [15:05:36.311] foo
#> INFO [15:05:38.156] overriden msg +#> FATAL [15:05:38.158] overriden msg