@@ -39,18 +39,19 @@ Appenders.
3939 can write to the console, a logfile, a database, etc… .
4040 - Allow for * custom fields* in log events. As opposed to many other
4141 logging packages for R a log event is not just a message with a
42- timestamp, but can contain arbitrary data fields. This is very
43- helpful if you want to produce logs that are machine readable and
44- easy to analyze.
42+ timestamp, but an object that can contain arbitrary data fields.
43+ This is useful for producing machine readable logs.
4544 - * Vectorized* logging (so ` lgr$fatal(capture.output(iris)) ` works)
46- - Lightning fast * in-memory log* based in ` data.table ` included for
47- interactive use.
48- - Comes with a * wide range of appenders* , for example for:
49- - Appending to Databases (buffered or directly)
50- - Sending notifications via email or pushbullet
51- - writing JSON with arbitrary data fields
52- - In memory buffers
53- - colored console output
45+ - Lightning fast * in-memory logs* for interactive use.
46+ - Appenders that write logs to a wide range of destinations:
47+ - databases (buffered or directly)
48+ - email or pushbullet
49+ - plaintext files (with a powerful formatting syntax)
50+ - JSON files with arbitrary data fields
51+ - Rotating files that are reset and backed-up after they reach a
52+ certain file size or age
53+ - memory buffers
54+ - (colored) console output
5455 - Optional support to use [ glue] ( https://glue.tidyverse.org/ ) instead
5556 of ` sprintf() ` for composing log messages.
5657
@@ -64,13 +65,13 @@ vignette.
6465
6566``` r
6667lgr $ fatal(" A critical error" )
67- # > FATAL [06:42:54.110 ] A critical error
68+ # > FATAL [08:25:07.182 ] A critical error
6869lgr $ error(" A less severe error" )
69- # > ERROR [06:42:54.139 ] A less severe error
70+ # > ERROR [08:25:07.211 ] A less severe error
7071lgr $ warn(" A potentially bad situation" )
71- # > WARN [06:42:54.150 ] A potentially bad situation
72+ # > WARN [08:25:07.221 ] A potentially bad situation
7273lgr $ info(" iris has %s rows" , nrow(iris ))
73- # > INFO [06:42:54.152 ] iris has 150 rows
74+ # > INFO [08:25:07.223 ] iris has 150 rows
7475
7576# the following log levels are hidden by default
7677lgr $ debug(" A debug message" )
@@ -84,9 +85,9 @@ appender to log to a file with little effort.
8485tf <- tempfile()
8586lgr $ add_appender(AppenderFile $ new(tf , layout = LayoutJson $ new()))
8687lgr $ info(" cars has %s rows" , nrow(cars ))
87- # > INFO [06:42:54.168 ] cars has 50 rows
88+ # > INFO [08:25:07.239 ] cars has 50 rows
8889cat(readLines(tf ))
89- # > {"level":400,"timestamp":"2019-05-23 06:42:54 ","logger":"root","caller":"eval","msg":"cars has 50 rows"}
90+ # > {"level":400,"timestamp":"2019-06-11 08:25:07 ","logger":"root","caller":"eval","msg":"cars has 50 rows"}
9091```
9192
9293By passing a named argument to ` info() ` , ` warn() ` , and co you can log
@@ -96,17 +97,17 @@ logfiles that are machine as well as (somewhat) human readable.
9697
9798``` r
9899lgr $ info(" loading cars" , " cars" , rows = nrow(cars ), cols = ncol(cars ))
99- # > INFO [06:42:54.191 ] loading cars {rows: 50, cols: 2}
100+ # > INFO [08:25:07.258 ] loading cars {rows: 50, cols: 2}
100101cat(readLines(tf ), sep = " \n " )
101- # > {"level":400,"timestamp":"2019-05-23 06:42:54 ","logger":"root","caller":"eval","msg":"cars has 50 rows"}
102- # > {"level":400,"timestamp":"2019-05-23 06:42:54 ","logger":"root","caller":"eval","msg":"loading cars","rows":50,"cols":2}
102+ # > {"level":400,"timestamp":"2019-06-11 08:25:07 ","logger":"root","caller":"eval","msg":"cars has 50 rows"}
103+ # > {"level":400,"timestamp":"2019-06-11 08:25:07 ","logger":"root","caller":"eval","msg":"loading cars","rows":50,"cols":2}
103104```
104105
105106For more examples please see the package
106107[ vignette] ( https://s-fleck.github.io/lgr/articles/lgr.html ) and
107108[ documentation] ( https://s-fleck.github.io/lgr/ )
108109
109- ## See lgr in Action
110+ ## See lgr in action
110111
111112lgr is used to govern console output in my shiny based csv editor
112113[ shed] ( https://github.com/s-fleck/shed )
@@ -132,7 +133,7 @@ readLines(logfile)
132133file.remove(logfile )
133134```
134135
135- ## Development Status
136+ ## Development status
136137
137138The api of lgr is stable and safe for use. The internal implementation
138139of the database logging features still needs some refinement, and if you
@@ -146,29 +147,26 @@ encouraged.
146147
147148[ R6] ( https://github.com/r-lib/R6 ) : The R6 class system provides the
148149framework on which lgr is built and the ** only Package lgr will ever
149- depend on** .
150+ depend on** . If you are a ** package developer** and want to add logging
151+ to your package, this is the only transitive dependency you have to
152+ worry about, as configuring of the loggers should be left to the user of
153+ your package.
150154
151- ### Optional Dependencies
155+ ### Optional dependencies
152156
153157lgr comes with a long list of optional dependencies that make a wide
154158range of appenders possible. You only need the dependencies for the
155- appenders you actually want to use. If you are a developer and want to
156- use lgr in one of your packages, you do not have to worry about these
157- dependencies (configuring loggers should be left to the user of your
158- package).
159+ Appenders you actually want to use. Care was taken to choose packages
160+ that are slim, stable, have minimal dependencies, and are well
161+ maintained :
159162
160- Care was taken to choose packages that are slim, stable, have minimal
161- dependencies, and are well maintained :
163+ Extra appenders (and layouts):
162164
163- - [ crayon] ( https://github.com/r-lib/crayon ) for colored console
164- output.
165- - [ glue] ( https://glue.tidyverse.org/ ) for a more flexible formatting
166- syntax via LoggerGlue and LayoutGlue.
167- - [ data.table] ( https://github.com/Rdatatable/ ) for fast in-memory
168- logging with ` AppenderDt ` , and also by all database / DBI Appenders.
169165 - [ jsonlite] ( https://github.com/jeroen/jsonlite ) for JSON logging via
170166 ` LayoutJson ` . JSON is a popular plaintext based file format that is
171167 easy to read for humans and machines alike.
168+ - [ rotor] ( https://github.com/s-fleck/rotor ) for log rotation via
169+ AppenderFileRotating and co.
172170 - [ DBI] ( https://github.com/r-dbi/DBI ) for logging to databases. lgr is
173171 confirmed to work with the following backends:
174172 - [ RSQLite] ( https://github.com/r-dbi/RSQLite ) ,
@@ -181,23 +179,33 @@ dependencies, and are well maintained :
181179 are using lgr with a database backend, please report your (positive
182180 and negative) experiences, as database support is still somewhat
183181 experimental.
182+ - [ data.table] ( https://github.com/Rdatatable/ ) for fast in-memory
183+ logging with ` AppenderDt ` , and also by all database / DBI Appenders.
184184 - [ gmailr] ( https://cran.r-project.org/package=gmailr ) or
185185 [ sendmailR] ( https://cran.r-project.org/package=sendmailR ) for email
186186 notifications.
187187 - [ RPushbullet] ( https://github.com/eddelbuettel/rpushbullet ) for push
188188 notifications.
189+ - [ glue] ( https://glue.tidyverse.org/ ) for a more flexible formatting
190+ syntax via LoggerGlue and LayoutGlue.
191+
192+ Other extra features:
193+
194+ - [ yaml] ( https://CRAN.R-project.org/package=yaml ) for configuring
195+ loggers via YAML files
196+ - [ crayon] ( https://github.com/r-lib/crayon ) for colored console
197+ output.
189198 - [ whoami] ( https://github.com/r-lib/whoami/blob/master/DESCRIPTION )
190199 for guessing the user name from various sources. You can also set
191200 the user name manually if you want to use it for logging.
192201 - [ desc] ( https://CRAN.R-project.org/package=desc ) for the package
193202 development convenience function ` use_logger() `
194- - [ yaml] ( https://CRAN.R-project.org/package=yaml ) for configuring
195- loggers via YAML files
196- - [ rotor] ( https://github.com/s-fleck/rotor ) for log rotation via
197- AppenderFileRotating and co.
203+ - [ cli] ( https://CRAN.R-project.org/package=cli ) for printing the tree
204+ structure of registered loggers with ` logger_tree() `
198205
199- Other optional dependencies (future, future.apply) do not provide any
200- extra functionality but had to be included as Suggests for some of the
206+ Other ` Suggests ` ([ future] ( https://CRAN.R-project.org/package=future ) ,
207+ [ future.apply] ( https://CRAN.R-project.org/package=future.apply ) ) do not
208+ provide extra functionality but had to be included for some of the
201209automated unit tests run by lgr.
202210
203211## Installation
0 commit comments