@@ -46,7 +46,7 @@ tf <- tempfile(fileext = ".info")
4646lgr $ add_appender(AppenderFile $ new(tf ), name = " file" )
4747lgr $ info(" You must think I am joking" )
4848readLines(tf )
49- # > [1] "INFO [2026-01-30 11:27:48.131 ] You must think I am joking"
49+ # > [1] "INFO [2026-01-30 11:47:42.001 ] You must think I am joking"
5050```
5151
5252The various Appenders available in lgr are R6 classes. To instantiate an
@@ -63,8 +63,8 @@ exactly one:
6363lgr $ appenders $ file $ set_layout(LayoutFormat $ new(timestamp_fmt = " %B %d %T" ))
6464lgr $ info(" No, I am quite serious" )
6565readLines(tf )
66- # > [1] "INFO [2026-01-30 11:27:48.131 ] You must think I am joking"
67- # > [2] "INFO [January 30 11:27:48 ] No, I am quite serious"
66+ # > [1] "INFO [2026-01-30 11:47:42.001 ] You must think I am joking"
67+ # > [2] "INFO [January 30 11:47:42 ] No, I am quite serious"
6868
6969# cleanup
7070unlink(tf )
@@ -89,15 +89,15 @@ JSON is still somewhat human readable
8989
9090``` r
9191cat(readLines(tf ))
92- # > {"level":400,"timestamp":"2026-01-30 11:27:48 ","logger":"root","caller":"eval","msg":"We lived in Styria"}
92+ # > {"level":400,"timestamp":"2026-01-30 11:47:42 ","logger":"root","caller":"eval","msg":"We lived in Styria"}
9393```
9494
9595and easy for machines to parse
9696
9797``` r
9898read_json_lines(tf )
9999# > level timestamp logger caller msg
100- # > 1 400 2026-01-30 11:27:48 root eval We lived in Styria
100+ # > 1 400 2026-01-30 11:47:42 root eval We lived in Styria
101101```
102102
103103Many Appenders provide either a ` $show() ` method and a ` $data ` active
@@ -108,13 +108,13 @@ binding convenience, and so you do not have to call
108108# show is a method and takes some extra arguments, like maximum number of lines
109109# to show
110110lgr $ appenders $ json $ show()
111- # > {"level":400,"timestamp":"2026-01-30 11:27:48 ","logger":"root","caller":"eval","msg":"We lived in Styria"}
111+ # > {"level":400,"timestamp":"2026-01-30 11:47:42 ","logger":"root","caller":"eval","msg":"We lived in Styria"}
112112
113113# $data always returns a data.frame if available. It is an active binding
114114# rather than a method, so no extra arguments are possible
115115lgr $ appenders $ json $ data
116116# > level timestamp logger caller msg
117- # > 1 400 2026-01-30 11:27:48 root eval We lived in Styria
117+ # > 1 400 2026-01-30 11:47:42 root eval We lived in Styria
118118```
119119
120120Please note that under the hood, ` AppenderJson ` is just an
@@ -135,8 +135,8 @@ lgr$info("Styria has", poultry = c("capons", "turkeys"))
135135# JSON can store most R objects quite naturally
136136read_json_lines(tf )
137137# > level timestamp logger caller msg poultry
138- # > 1 400 2026-01-30 11:27:48 root eval We lived in Styria NULL
139- # > 2 400 2026-01-30 11:27:48 root eval Styria has capons, turkeys
138+ # > 1 400 2026-01-30 11:47:42 root eval We lived in Styria NULL
139+ # > 2 400 2026-01-30 11:47:42 root eval Styria has capons, turkeys
140140read_json_lines(tf )$ poultry [[2 ]] # works because poultry is a list column
141141# > [1] "capons" "turkeys"
142142```
@@ -269,13 +269,13 @@ last event produced by a Logger is stored in its `last_event` field.
269269``` r
270270lgr $ info(" Vampire stories are generally located in Styria" )
271271lgr $ last_event # a summary output of the event
272- # > INFO [2026-01-30 11:27:48 ] Vampire stories are generally located in Styria
272+ # > INFO [2026-01-30 11:47:42 ] Vampire stories are generally located in Styria
273273lgr $ last_event $ values # all values stored in the event as a list
274274# > $level
275275# > [1] 400
276276# >
277277# > $timestamp
278- # > [1] "2026-01-30 11:27:48 UTC"
278+ # > [1] "2026-01-30 11:47:42 UTC"
279279# >
280280# > $logger
281281# > [1] "root"
@@ -311,7 +311,7 @@ lgr$add_appender(AppenderJson$new(tf), "json")
311311lgr $ info(" Processing track" , file = " track.gpx" , waypoints = 32 )
312312lgr $ appenders $ json $ data
313313# > level timestamp logger caller msg file waypoints
314- # > 1 400 2026-01-30 11:27:48 root eval Processing track track.gpx 32
314+ # > 1 400 2026-01-30 11:47:42 root eval Processing track track.gpx 32
315315```
316316
317317### Thresholds & Filters: controlling output detail
@@ -366,8 +366,8 @@ lgr$info("Another informational message")
366366lgr $ debug(" A debug message not shown by the console appender" )
367367
368368readLines(tf )
369- # > [1] "INFO [2026-01-30 11:27:49.177 ] Another informational message"
370- # > [2] "DEBUG [2026-01-30 11:27:49.179 ] A debug message not shown by the console appender"
369+ # > [1] "INFO [2026-01-30 11:47:43.060 ] Another informational message"
370+ # > [2] "DEBUG [2026-01-30 11:47:43.062 ] A debug message not shown by the console appender"
371371
372372# Remove the appender again
373373lgr $ remove_appender(" file" )
@@ -612,9 +612,9 @@ read_json_lines(tf)
612612```
613613
614614 #> level timestamp logger caller msg field numbers use
615- #> 1 400 2026-01-30 11:27:49 test eval JSON naturally custom NULL <NA>
616- #> 2 400 2026-01-30 11:27:49 test eval supports custom <NA> 1, 2, 3 <NA>
617- #> 3 400 2026-01-30 11:27:49 test eval log fields <NA> NULL JSON
615+ #> 1 400 2026-01-30 11:47:43 test eval JSON naturally custom NULL <NA>
616+ #> 2 400 2026-01-30 11:47:43 test eval supports custom <NA> 1, 2, 3 <NA>
617+ #> 3 400 2026-01-30 11:47:43 test eval log fields <NA> NULL JSON
618618
619619JSON is also human readable, though this vignette does not transport
620620that fact very well because of the lack of horizontal space.
@@ -625,9 +625,9 @@ lg$appenders$json$show()
625625cat(readLines(tf ), sep = " \n " )
626626```
627627
628- #> {"level":400,"timestamp":"2026-01-30 11:27:49 ","logger":"test","caller":"eval","msg":"JSON naturally ","field":"custom"}
629- #> {"level":400,"timestamp":"2026-01-30 11:27:49 ","logger":"test","caller":"eval","msg":"supports custom","numbers":[1,2,3]}
630- #> {"level":400,"timestamp":"2026-01-30 11:27:49 ","logger":"test","caller":"eval","msg":"log fields","use":"JSON"}
628+ #> {"level":400,"timestamp":"2026-01-30 11:47:43 ","logger":"test","caller":"eval","msg":"JSON naturally ","field":"custom"}
629+ #> {"level":400,"timestamp":"2026-01-30 11:47:43 ","logger":"test","caller":"eval","msg":"supports custom","numbers":[1,2,3]}
630+ #> {"level":400,"timestamp":"2026-01-30 11:47:43 ","logger":"test","caller":"eval","msg":"log fields","use":"JSON"}
631631
632632``` r
633633# cleanup
@@ -663,17 +663,17 @@ for (i in 1:100) lg$info(paste(LETTERS, sep = "-"))
663663# display info on the backups of tf
664664lg $ appenders $ rotating $ backups
665665# > path name sfx ext size isdir
666- # > 1 /tmp/RtmpDPfMuU/file1fa31f7cc0ae .1.log file1fa31f7cc0ae 1 log 10608 FALSE
667- # > 2 /tmp/RtmpDPfMuU/file1fa31f7cc0ae .2.log file1fa31f7cc0ae 2 log 10608 FALSE
668- # > 3 /tmp/RtmpDPfMuU/file1fa31f7cc0ae .3.log file1fa31f7cc0ae 3 log 10608 FALSE
669- # > 4 /tmp/RtmpDPfMuU/file1fa31f7cc0ae .4.log file1fa31f7cc0ae 4 log 10608 FALSE
670- # > 5 /tmp/RtmpDPfMuU/file1fa31f7cc0ae .5.log file1fa31f7cc0ae 5 log 10608 FALSE
666+ # > 1 /tmp/RtmpgGWvJo/file1f104b166096 .1.log file1f104b166096 1 log 10608 FALSE
667+ # > 2 /tmp/RtmpgGWvJo/file1f104b166096 .2.log file1f104b166096 2 log 10608 FALSE
668+ # > 3 /tmp/RtmpgGWvJo/file1f104b166096 .3.log file1f104b166096 3 log 10608 FALSE
669+ # > 4 /tmp/RtmpgGWvJo/file1f104b166096 .4.log file1f104b166096 4 log 10608 FALSE
670+ # > 5 /tmp/RtmpgGWvJo/file1f104b166096 .5.log file1f104b166096 5 log 10608 FALSE
671671# > mode mtime ctime atime uid gid
672- # > 1 644 2026-01-30 11:27:50 2026-01-30 11:27:50 2026-01-30 11:27:50 1001 1001
673- # > 2 644 2026-01-30 11:27:50 2026-01-30 11:27:50 2026-01-30 11:27:50 1001 1001
674- # > 3 644 2026-01-30 11:27:50 2026-01-30 11:27:50 2026-01-30 11:27:50 1001 1001
675- # > 4 644 2026-01-30 11:27:50 2026-01-30 11:27:50 2026-01-30 11:27:50 1001 1001
676- # > 5 644 2026-01-30 11:27:50 2026-01-30 11:27:50 2026-01-30 11:27:50 1001 1001
672+ # > 1 644 2026-01-30 11:47:44 2026-01-30 11:47:44 2026-01-30 11:47:44 1001 1001
673+ # > 2 644 2026-01-30 11:47:44 2026-01-30 11:47:44 2026-01-30 11:47:44 1001 1001
674+ # > 3 644 2026-01-30 11:47:44 2026-01-30 11:47:44 2026-01-30 11:47:44 1001 1001
675+ # > 4 644 2026-01-30 11:47:44 2026-01-30 11:47:44 2026-01-30 11:47:44 1001 1001
676+ # > 5 644 2026-01-30 11:47:44 2026-01-30 11:47:44 2026-01-30 11:47:44 1001 1001
677677# > uname grname index
678678# > 1 runner runner 1
679679# > 2 runner runner 2
@@ -714,7 +714,7 @@ print(lg)
714714# > <Logger> [all] mypackage
715715# >
716716# > appenders:
717- # > [[1]]: <AppenderFile> [all] -> /tmp/RtmpDPfMuU/file1fa3789c29c2
717+ # > [[1]]: <AppenderFile> [all] -> /tmp/RtmpgGWvJo/file1f104b9d2fe6
718718# >
719719# > inherited appenders:
720720# > console: <AppenderConsole> [info] -> console
@@ -748,7 +748,7 @@ print(lg)
748748# > <Logger> [all] mypackage
749749# >
750750# > appenders:
751- # > [[1]]: <AppenderFile> [all] -> /tmp/RtmpDPfMuU/file1fa3789c29c2
751+ # > [[1]]: <AppenderFile> [all] -> /tmp/RtmpgGWvJo/file1f104b9d2fe6
752752```
753753
754754Consequently, ` lg ` no longer outputs log messages to he console
0 commit comments