Skip to content

Commit 54c1667

Browse files
tkfKristofferC
authored andcommitted
Always use Symbol as _group value of log records (#34509)
1 parent 4eab1bf commit 54c1667

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

base/logging.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ function log_record_id(_module, level, message, log_kws)
248248
end
249249
end
250250

251+
default_group(file) = Symbol(splitext(basename(file))[1])
252+
251253
# Generate code for logging macros
252254
function logmsg_code(_module, file, line, level, message, exs...)
253255
id = Expr(:quote, log_record_id(_module, level, message, exs))
@@ -293,12 +295,12 @@ function logmsg_code(_module, file, line, level, message, exs...)
293295
if group === nothing
294296
group = if isdefined(Base, :basename) && isa(file, String)
295297
# precompute if we can
296-
QuoteNode(splitext(basename(file))[1])
298+
QuoteNode(default_group(file))
297299
else
298300
# memoized run-time execution
299301
ref = Ref{Symbol}()
300302
:(isassigned($ref) ? $ref[]
301-
: $ref[] = Symbol(splitext(basename(something($file, "")))[1]))
303+
: $ref[] = default_group(something($file, "")))
302304
end
303305
end
304306

test/logging.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,4 +384,12 @@ end
384384
@test logs[1].id != logs[2].id
385385
end
386386

387+
# Issue #34485
388+
@testset "`_group` must be a `Symbol`" begin
389+
(record,), _ = collect_test_logs() do
390+
@info "test"
391+
end
392+
@test record.group == :logging # name of this file
393+
end
394+
387395
end

0 commit comments

Comments
 (0)