Skip to content

Commit 1f5efa9

Browse files
committed
Rename log_args to log
1 parent c86ca31 commit 1f5efa9

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/Sinks/formatlogger.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ end
99
FormatLogger(formatter, io::IO=stderr; always_flush=true)
1010
1111
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:
1414
`(level, message, _module, group, id, file, line, kwargs)`.
1515
See [`LoggingExtras.handle_message_args`](@ref) for more information on what field is.
1616
1717
# Examples
1818
```julia-repl
1919
julia> using Logging, LoggingExtras
2020
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)
2323
end;
2424
2525
julia> with_logger(logger) do
@@ -49,12 +49,12 @@ function FormatLogger(formatter, path::AbstractString; append::Bool=false, kw...
4949
end
5050

5151
function handle_message(logger::FormatLogger, args...; kwargs...)
52-
log_args = handle_message_args(args...; kwargs...)
52+
log = handle_message_args(args...; kwargs...)
5353
# We help the user by passing an IOBuffer to the formatting function
5454
# to make sure that everything writes to the logger io in one go.
5555
iob = IOBuffer()
5656
ioc = IOContext(iob, logger.stream)
57-
logger.formatter(ioc, log_args)
57+
logger.formatter(ioc, log)
5858
write(logger.stream, take!(iob))
5959
logger.always_flush && flush(logger.stream)
6060
return nothing

test/runtests.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,23 +201,23 @@ Base.@kwdef struct BasicLogFormatter
201201
include_module::Bool=true
202202
end
203203

204-
function (formatter::BasicLogFormatter)(io::IO, args::NamedTuple)
204+
function (formatter::BasicLogFormatter)(io::IO, log::NamedTuple)
205205
if formatter.include_module
206-
print(io, args._module, " | ")
206+
print(io, log._module, " | ")
207207
end
208-
println(io, "[", args.level, "] ", args.message)
208+
println(io, "[", log.level, "] ", log.message)
209209
end
210210

211211
@testset "FormatLogger" begin
212212
io = IOBuffer()
213-
logger = FormatLogger(io) do io, args
213+
logger = FormatLogger(io) do io, log
214214
# Put in some bogus sleep calls just to test that
215215
# log records writes in one go
216-
print(io, args.level)
216+
print(io, log.level)
217217
sleep(rand())
218218
print(io, ": ")
219219
sleep(rand())
220-
println(io, args.message)
220+
println(io, log.message)
221221
end
222222
with_logger(logger) do
223223
@sync begin
@@ -242,7 +242,7 @@ end
242242
mktempdir() do dir
243243
f = joinpath(dir, "test.log")
244244

245-
logger = FormatLogger(f) do io, args
245+
logger = FormatLogger(f) do io, log
246246
println(io, "log message")
247247
end
248248

0 commit comments

Comments
 (0)