Skip to content

Commit

Permalink
Add support for "all except x" in JULIA_DEBUG (#32432)
Browse files Browse the repository at this point in the history
  • Loading branch information
DilumAluthge authored and vtjnash committed Sep 23, 2019
1 parent 36220ed commit b13c64a
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 34 deletions.
51 changes: 31 additions & 20 deletions base/logging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -413,38 +413,49 @@ function disable_logging(level::LogLevel)
_min_enabled_level[] = level + 1
end

let _debug_groups = Symbol[],
let _debug_groups_include::Vector{Symbol} = Symbol[],
_debug_groups_exclude::Vector{Symbol} = Symbol[],
_debug_str::String = ""
global function env_override_minlevel(group, _module)
debug = get(ENV, "JULIA_DEBUG", "")
if !(debug === _debug_str)
_debug_str = debug
empty!(_debug_groups)
empty!(_debug_groups_include)
empty!(_debug_groups_exclude)
for g in split(debug, ',')
isempty(g) && continue
if g == "all"
empty!(_debug_groups)
push!(_debug_groups, :all)
break
if !isempty(g)
if startswith(g, "!")
if !isempty(g[2:end])
push!(_debug_groups_exclude, Symbol(g[2:end]))
end
else
push!(_debug_groups_include, Symbol(g))
end
end
push!(_debug_groups, Symbol(g))
end
unique!(_debug_groups_include)
unique!(_debug_groups_exclude)
end
if isempty(_debug_groups)
return false
end
if _debug_groups[1] == :all
return true
end
if isa(group, Symbol) && group in _debug_groups
return true
end
if isa(_module, Module)
if nameof(_module) in _debug_groups

if !(:all in _debug_groups_exclude) && (:all in _debug_groups_include || !isempty(_debug_groups_exclude))
if isempty(_debug_groups_exclude)
return true
elseif isa(group, Symbol) && group in _debug_groups_exclude
return false
elseif isa(_module, Module) && (nameof(_module) in _debug_groups_exclude || nameof(Base.moduleroot(_module)) in _debug_groups_exclude)
return false
else
return true
end
if nameof(Base.moduleroot(_module)) in _debug_groups
else
if isempty(_debug_groups_include)
return false
elseif isa(group, Symbol) && group in _debug_groups_include
return true
elseif isa(_module, Module) && (nameof(_module) in _debug_groups_include || nameof(Base.moduleroot(_module)) in _debug_groups_include)
return true
else
return false
end
end
return false
Expand Down
60 changes: 46 additions & 14 deletions test/logging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,52 @@ end
logger = TestLogger()
with_logger(logger) do
for (e, r) in (("", false),
(",,,,", false),
("al", false),
("all", true),
("a,b,all,c", true),
("a,b,,c", false),
("Mainb", false),
("aMain", false),
("Main", true),
("a,b,Main,c", true),
("Base", true),
("a,b,Base,c", true),
("Filesystem", true),
("a,b,Filesystem,c", true),
("a,b,Base.Filesystem,c", false))
(",,,,", false),
("al", false),
("all", true),
("a,b,all,c", true),
("a,b,,c", false),
("Mainb", false),
("aMain", false),
("Main", true),
("a,b,Main,c", true),
("Base", true),
("a,b,Base,c", true),
("Filesystem", true),
("a,b,Filesystem,c", true),
("a,b,Base.Filesystem,c", false),
("!al", true),
("all,!al", true),
("all,!al,!all", false),
("!all,Main", true),
("!all,!Main", false),
("!all,a,b,!Main,c", false),
("!all,Filesystem", true),
("!all,Base.Filesystem", false),
("a,b,all,!all,c", false),
("!Main", false),
("a,b,!Main,c", false),
("!Base", false),
("all,!Base", false),
("!all,Base", true),
("!all,!Base", false),
("a,b,!Base,c", false),
("all,a,b,!Base,c", false),
("!all,a,b,Base,c", true),
("!all,a,b,!Base,c", false),
("!Filesystem", false),
("all,!Filesystem", false),
("!all,Filesystem", true),
("!all,!Filesystem", false),
("a,b,!Filesystem,c", false),
("all,a,b,!Filesystem,c", false),
("!all,a,b,Filesystem,c", true),
("!all,a,b,!Filesystem,c", false),
("a,b,!Base.Filesystem,c", true),
("all,a,b,!Base.Filesystem,c", true),
("!all,a,b,Base.Filesystem,c", false),
("!all,a,b,!Base.Filesystem,c", false),
)
ENV["JULIA_DEBUG"] = e
@test CoreLogging.env_override_minlevel(:Main, Base.Filesystem) === r
@test CoreLogging.current_logger_for_env(BelowMinLevel, :Main, Base.Filesystem) === (r ? logger : nothing)
Expand Down

2 comments on commit b13c64a

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.