@@ -50,8 +50,7 @@ ConsoleLogger(stream, min_level) =
50
50
51
51
# Usage
52
52
Load the package with ` using LoggingExtras ` .
53
- You likely also want to load the ` Logging ` standard lib.
54
- Loggers can be constructed and used like normal.
53
+ For convenience, this also re-exports the ` Logging ` standard library.
55
54
56
55
57
56
### Basics of working with loggers
@@ -154,7 +153,7 @@ see the HTTP example below.
154
153
Another example is using them to stop messages every being repeated within a given time period.
155
154
156
155
``` julia
157
- using Dates, Logging, LoggingExtras
156
+ using Dates, LoggingExtras
158
157
159
158
julia> function make_throttled_logger (period)
160
159
history = Dict {Symbol, DateTime} ()
@@ -196,7 +195,7 @@ that just checks if the level of the message is above the level specified when i
196
195
### Demo: filter out all the log messages that are less severe than `Error`
197
196
198
197
``` julia
199
- julia> using Logging, LoggingExtras
198
+ julia> using LoggingExtras
200
199
201
200
julia> error_only_logger = MinLevelLogger (current_logger (), Logging. Error);
202
201
@@ -222,7 +221,7 @@ and should return a new modified named tuple.
222
221
A simple example of its use is truncating messages.
223
222
224
223
``` julia
225
- julia> using Logging, LoggingExtras
224
+ julia> using LoggingExtras
226
225
227
226
julia> truncating_logger = TransformerLogger (global_logger ()) do log
228
227
if length (log. message) > 128
@@ -263,7 +262,7 @@ We are going to log info and above to one file,
263
262
and warnings and above to another.
264
263
265
264
``` julia
266
- julia> using Logging; using LoggingExtras;
265
+ julia> using LoggingExtras;
267
266
268
267
julia> demux_logger = TeeLogger (
269
268
MinLevelLogger (FileLogger (" info.log" ), Logging. Info),
@@ -299,7 +298,7 @@ when the `DateFormat` would change the filename. Note that if you wish to have
299
298
escape them so they are not interpreted by the `DateFormat` code. Example:
300
299
301
300
``` julia
302
- julia> using Logging, LoggingExtras
301
+ julia> using LoggingExtras
303
302
304
303
julia> rotating_logger = DatetimeRotatingFileLogger (pwd (), raw " \a\c\c\e\s\s -YYYY-mm-dd-HH-MM-SS.\l\o\g " );
305
304
@@ -327,7 +326,7 @@ The `FormatLogger` is a sink that formats the message and prints to a wrapped IO
327
326
Formatting is done by providing a function `f(io::IO, log_args::NamedTuple)`.
328
327
329
328
``` julia
330
- julia> using Logging, LoggingExtras
329
+ julia> using LoggingExtras
331
330
332
331
julia> logger = FormatLogger () do io, args
333
332
println (io, args. _module, " | " , " [" , args. level, " ] " , args. message)
@@ -347,7 +346,6 @@ Main | [Warn] This is a warning, should take a look.
347
346
348
347
``` julia
349
348
using LoggingExtras
350
- using Logging
351
349
352
350
function sensible_message_filter (log)
353
351
length (log. message) < 1028
@@ -361,7 +359,6 @@ global_logger(ActiveFilteredLogger(sensible_message_filter, global_logger()))
361
359
362
360
``` julia
363
361
using LoggingExtras
364
- using Logging
365
362
using HTTP
366
363
367
364
function not_HTTP_message_filter (log)
@@ -375,7 +372,6 @@ global_logger(EarlyFilteredLogger(not_HTTP_message_filter, global_logger()))
375
372
376
373
``` julia
377
374
using LoggingExtras
378
- using Logging
379
375
using HTTP
380
376
381
377
transformer_logger (global_logger ()) do log
@@ -394,7 +390,7 @@ global_logger(transformer_logger)
394
390
## Add timestamp to all logging
395
391
396
392
``` julia
397
- using Logging, LoggingExtras, Dates
393
+ using LoggingExtras, Dates
398
394
399
395
const date_format = " yyyy-mm-dd HH:MM:SS"
400
396
0 commit comments