@@ -28,28 +28,28 @@ Appenders.
2828
2929## Features
3030
31- - * Hierarchical loggers* like in log4j and python logging. This is
32- useful if you want to be able to configure logging on a per-package
33- basis.
34- - An * arbitrary number of appenders* for each logger. A single logger
35- can write to the console, a logfile, a database, etc… .
36- - Support for structured logging. As opposed to many other logging
37- packages for R a log event is not just a message with a timestamp,
38- but an object that can contain arbitrary data fields. This is useful
39- for producing machine readable logs.
40- - * Vectorized* logging (so ` lgr$fatal(capture.output(iris)) ` works)
41- - Lightning fast * in-memory logs* for interactive use.
42- - Appenders that write logs to a wide range of destinations:
43- - databases (buffered or directly)
44- - email or pushbullet
45- - plaintext files (with a powerful formatting syntax)
46- - JSON files with arbitrary data fields
47- - Rotating files that are reset and backed-up after they reach a
48- certain file size or age
49- - memory buffers
50- - (colored) console output
51- - Optional support to use [ glue] ( https://glue.tidyverse.org/ ) instead
52- of ` sprintf() ` for composing log messages.
31+ - * Hierarchical loggers* like in log4j and python logging. This is
32+ useful if you want to be able to configure logging on a per-package
33+ basis.
34+ - An * arbitrary number of appenders* for each logger. A single logger
35+ can write to the console, a logfile, a database, etc… .
36+ - Support for structured logging. As opposed to many other logging
37+ packages for R a log event is not just a message with a timestamp, but
38+ an object that can contain arbitrary data fields. This is useful for
39+ producing machine readable logs.
40+ - * Vectorized* logging (so ` lgr$fatal(capture.output(iris)) ` works)
41+ - Lightning fast * in-memory logs* for interactive use.
42+ - Appenders that write logs to a wide range of destinations:
43+ - databases (buffered or directly)
44+ - email or pushbullet
45+ - plaintext files (with a powerful formatting syntax)
46+ - JSON files with arbitrary data fields
47+ - Rotating files that are reset and backed-up after they reach a
48+ certain file size or age
49+ - memory buffers
50+ - (colored) console output
51+ - Optional support to use [ glue] ( https://glue.tidyverse.org/ ) instead of
52+ ` sprintf() ` for composing log messages.
5353
5454## Usage
5555
@@ -61,13 +61,13 @@ vignette.
6161
6262``` r
6363lgr $ fatal(" A critical error" )
64- # > FATAL [09:29:52.755 ] A critical error
64+ # > FATAL [20:38:17.998 ] A critical error
6565lgr $ error(" A less severe error" )
66- # > ERROR [09:29:52.777 ] A less severe error
66+ # > ERROR [20:38:18.057 ] A less severe error
6767lgr $ warn(" A potentially bad situation" )
68- # > WARN [09:29:52.784 ] A potentially bad situation
68+ # > WARN [20:38:18.072 ] A potentially bad situation
6969lgr $ info(" iris has %s rows" , nrow(iris ))
70- # > INFO [09:29:52.785 ] iris has 150 rows
70+ # > INFO [20:38:18.074 ] iris has 150 rows
7171
7272# the following log levels are hidden by default
7373lgr $ debug(" A debug message" )
@@ -81,9 +81,9 @@ appender to log to a file with little effort.
8181tf <- tempfile()
8282lgr $ add_appender(AppenderFile $ new(tf , layout = LayoutJson $ new()))
8383lgr $ info(" cars has %s rows" , nrow(cars ))
84- # > INFO [09:29:52.805 ] cars has 50 rows
84+ # > INFO [20:38:18.173 ] cars has 50 rows
8585cat(readLines(tf ))
86- # > {"level":400,"timestamp":"2022-04-28 09:29:52 ","logger":"root","caller":"eval","msg":"cars has 50 rows"}
86+ # > {"level":400,"timestamp":"2023-03-04 20:38:18 ","logger":"root","caller":"eval","msg":"cars has 50 rows"}
8787```
8888
8989By passing a named argument to ` info() ` , ` warn() ` , and co you can log
@@ -94,10 +94,10 @@ logfiles that are machine as well as (somewhat) human readable.
9494``` r
9595lgr $ info(" loading cars" , " cars" , rows = nrow(cars ), cols = ncol(cars ))
9696# > Warning in (function (fmt, ...) : one argument not used by format 'loading cars'
97- # > INFO [09:29:52.832 ] loading cars {rows: `50`, cols: `2`}
97+ # > INFO [20:38:18.263 ] loading cars {rows: `50`, cols: `2`}
9898cat(readLines(tf ), sep = " \n " )
99- # > {"level":400,"timestamp":"2022-04-28 09:29:52 ","logger":"root","caller":"eval","msg":"cars has 50 rows"}
100- # > {"level":400,"timestamp":"2022-04-28 09:29:52 ","logger":"root","caller":"eval","msg":"loading cars","rows":50,"cols":2}
99+ # > {"level":400,"timestamp":"2023-03-04 20:38:18 ","logger":"root","caller":"eval","msg":"cars has 50 rows"}
100+ # > {"level":400,"timestamp":"2023-03-04 20:38:18 ","logger":"root","caller":"eval","msg":"loading cars","rows":50,"cols":2}
101101```
102102
103103For more examples please see the package
@@ -135,13 +135,13 @@ file.remove(logfile)
135135lgr in general is stable and safe for use, but ** the following features
136136are still experimental** :
137137
138- - Database appenders which are available from the separate package
139- [ lgrExtra] ( https://github.com/s-fleck/lgrExtra ) .
140- - yaml/json config files for loggers (do not yet support all planned
141- features)
142- - The documentation in general. I’m still hoping for more R6-specific
143- features in [ roxygen2] ( https://github.com/r-lib/roxygen2 ) before I
144- invest more time in object documentation.
138+ - Database appenders which are available from the separate package
139+ [ lgrExtra] ( https://github.com/s-fleck/lgrExtra ) .
140+ - yaml/json config files for loggers (do not yet support all planned
141+ features)
142+ - The documentation in general. I’m still hoping for more R6-specific
143+ features in [ roxygen2] ( https://github.com/r-lib/roxygen2 ) before I
144+ invest more time in object documentation.
145145
146146## Dependencies
147147
@@ -162,60 +162,62 @@ maintained :
162162
163163Extra appenders (in the main package):
164164
165- - [ jsonlite] ( https://github.com/jeroen/jsonlite ) for JSON logging via
166- ` LayoutJson ` . JSON is a popular plaintext based file format that is
167- easy to read for humans and machines alike.
165+ - [ jsonlite] ( https://github.com/jeroen/jsonlite ) for JSON logging via
166+ ` LayoutJson ` . JSON is a popular plaintext based file format that is
167+ easy to read for humans and machines alike.
168168
169- - [ rotor] ( https://github.com/s-fleck/rotor ) for log rotation via
170- AppenderFileRotating and co.
169+ - [ rotor] ( https://github.com/s-fleck/rotor ) for log rotation via
170+ AppenderFileRotating and co.
171171
172- - [ data.table] ( https://github.com/Rdatatable/ ) for fast in-memory
173- logging with ` AppenderDt ` , and also by all database / DBI Appenders.
172+ - [ data.table] ( https://github.com/Rdatatable/ ) for fast in-memory
173+ logging with ` AppenderDt ` , and also by all database / DBI Appenders.
174174
175- - [ glue] ( https://glue.tidyverse.org/ ) for a more flexible formatting
176- syntax via LoggerGlue and LayoutGlue.
175+ - [ glue] ( https://glue.tidyverse.org/ ) for a more flexible formatting
176+ syntax via LoggerGlue and LayoutGlue.
177177
178178Extra appenders via [ lgrExtra] ( https://github.com/s-fleck/lgrExtra ) :
179179
180- - [ DBI] ( https://github.com/r-dbi/DBI ) for logging to databases. lgr is
181- confirmed to work with the following backends:
180+ - [ DBI] ( https://github.com/r-dbi/DBI ) for logging to databases. lgr is
181+ confirmed to work with the following backends:
182182
183- - [ RSQLite] ( https://github.com/r-dbi/RSQLite ) ,
184- - [ RMariaDB] ( https://github.com/r-dbi/RMariaDB ) for MariaDB and
185- MySQL,
186- - [ RPostgres] ( https://cran.r-project.org/package=RPostgres ) ,
187- - [ RJDBC] ( https://github.com/s-u/RJDBC ) for DB2, and
188- - [ odbc] ( https://github.com/r-dbi/odbc ) also for DB2.
183+ - [ RSQLite] ( https://github.com/r-dbi/RSQLite ) ,
184+ - [ RMariaDB] ( https://github.com/r-dbi/RMariaDB ) for MariaDB and MySQL,
185+ - [ RPostgres] ( https://cran.r-project.org/package=RPostgres ) ,
186+ - [ RJDBC] ( https://github.com/s-u/RJDBC ) for DB2, and
187+ - [ odbc] ( https://github.com/r-dbi/odbc ) also for DB2.
189188
190- In theory all DBI compliant database packages should work. If you
191- are using lgr with a database backend, please report your (positive
192- and negative) experiences, as database support is still somewhat
193- experimental.
189+ In theory all DBI compliant database packages should work. If you are
190+ using lgr with a database backend, please report your (positive and
191+ negative) experiences, as database support is still somewhat
192+ experimental.
194193
195- - [ gmailr] ( https://cran.r-project.org/package=gmailr ) or
194+ - [ gmailr] ( https://cran.r-project.org/package=gmailr ) or
196195
197- - [ sendmailR] ( https://cran.r-project.org/package=sendmailR ) for email
198- notifications.
196+ - [ sendmailR] ( https://cran.r-project.org/package=sendmailR ) for email
197+ notifications.
199198
200- - [ RPushbullet] ( https://github.com/eddelbuettel/rpushbullet ) for push
201- notifications.
199+ - [ RPushbullet] ( https://github.com/eddelbuettel/rpushbullet ) for push
200+ notifications.
202201
203- - [ Rsyslog] ( https://cran.r-project.org/package=rsyslog ) for logging to
204- syslog on POSIX-compatible systems.
202+ - [ Rsyslog] ( https://cran.r-project.org/package=rsyslog ) for logging to
203+ syslog on POSIX-compatible systems.
204+
205+ - [ elastic] ( https://cran.r-project.org/package=elastic ) for logging to
206+ ElasticSearch
205207
206208Other extra features:
207209
208- - [ yaml] ( https://CRAN.R-project.org/package=yaml ) for configuring
209- loggers via YAML files
210- - [ crayon] ( https://github.com/r-lib/crayon ) for colored console
211- output.
212- - [ whoami] ( https://github.com/r-lib/whoami/blob/master/DESCRIPTION )
213- for guessing the user name from various sources. You can also set
214- the user name manually if you want to use it for logging.
215- - [ desc] ( https://CRAN.R-project.org/package=desc ) for the package
216- development convenience function ` use_logger() `
217- - [ cli] ( https://CRAN.R-project.org/package=cli ) for printing the tree
218- structure of registered loggers with ` logger_tree() `
210+ - [ yaml] ( https://CRAN.R-project.org/package=yaml ) for configuring
211+ loggers via YAML files
212+ - [ crayon] ( https://github.com/r-lib/crayon ) for colored console
213+ output.
214+ - [ whoami] ( https://github.com/r-lib/whoami/blob/master/DESCRIPTION ) for
215+ guessing the user name from various sources. You can also set the user
216+ name manually if you want to use it for logging.
217+ - [ desc] ( https://CRAN.R-project.org/package=desc ) for the package
218+ development convenience function ` use_logger() `
219+ - [ cli] ( https://CRAN.R-project.org/package=cli ) for printing the tree
220+ structure of registered loggers with ` logger_tree() `
219221
220222Other ` Suggests ` ([ future] ( https://CRAN.R-project.org/package=future ) ,
221223[ future.apply] ( https://CRAN.R-project.org/package=future.apply ) ) do not
@@ -246,5 +248,5 @@ to post a feature request on the issue tracker.
246248
247249## Acknowledgement
248250
249- - [ diagrams.net] ( https://app.diagrams.net/ ) for the flow chart in the
250- vignette
251+ - [ diagrams.net] ( https://app.diagrams.net/ ) for the flow chart in the
252+ vignette
0 commit comments