|
9 | 9 | FormatLogger(formatter, io::IO=stderr; always_flush=true) |
10 | 10 |
|
11 | 11 | Logger sink that formats the message and finally writes to `io`. |
12 | | -The formatting function should be of the form `formatter(io::IOContext, log_args::NamedTuple)` |
13 | | -where `log_args` has the following fields: |
| 12 | +The formatting function should be of the form `formatter(io::IOContext, log::NamedTuple)` |
| 13 | +where `log` has the following fields: |
14 | 14 | `(level, message, _module, group, id, file, line, kwargs)`. |
15 | 15 | See [`LoggingExtras.handle_message_args`](@ref) for more information on what field is. |
16 | 16 |
|
17 | 17 | # Examples |
18 | 18 | ```julia-repl |
19 | 19 | julia> using Logging, LoggingExtras |
20 | 20 |
|
21 | | -julia> logger = FormatLogger() do io, args |
22 | | - println(io, args._module, " | ", "[", args.level, "] ", args.message) |
| 21 | +julia> logger = FormatLogger() do io, log |
| 22 | + println(io, log._module, " | ", "[", log.level, "] ", log.message) |
23 | 23 | end; |
24 | 24 |
|
25 | 25 | julia> with_logger(logger) do |
@@ -49,12 +49,12 @@ function FormatLogger(formatter, path::AbstractString; append::Bool=false, kw... |
49 | 49 | end |
50 | 50 |
|
51 | 51 | function handle_message(logger::FormatLogger, args...; kwargs...) |
52 | | - log_args = handle_message_args(args...; kwargs...) |
| 52 | + log = handle_message_args(args...; kwargs...) |
53 | 53 | # We help the user by passing an IOBuffer to the formatting function |
54 | 54 | # to make sure that everything writes to the logger io in one go. |
55 | 55 | iob = IOBuffer() |
56 | 56 | ioc = IOContext(iob, logger.stream) |
57 | | - logger.formatter(ioc, log_args) |
| 57 | + logger.formatter(ioc, log) |
58 | 58 | write(logger.stream, take!(iob)) |
59 | 59 | logger.always_flush && flush(logger.stream) |
60 | 60 | return nothing |
|
0 commit comments