Skip to content

Commit

Permalink
Declare level type for default_metafmt (#37843)
Browse files Browse the repository at this point in the history
Makes `@nospecialize` use precisely `LogLevel` instead of `Any`.
  • Loading branch information
omus authored Oct 9, 2020
1 parent 9c62c32 commit c67d810
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions base/logging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ function logmsg_code(_module, file, line, level, message, exs...)
let
level = $level
std_level = convert(LogLevel, level)
if std_level >= getindex(_min_enabled_level)
if std_level >= _min_enabled_level[]
group = $(log_data._group)
_module = $(log_data._module)
logger = current_logger_for_env(std_level, group, _module)
Expand Down Expand Up @@ -458,7 +458,7 @@ function logmsg_shim(level, message, _module, group, id, file, line, kwargs)
end

# Global log limiting mechanism for super fast but inflexible global log limiting.
const _min_enabled_level = Ref(Debug)
const _min_enabled_level = Ref{LogLevel}(Debug)

# LogState - a cache of data extracted from the logger, plus the logger itself.
struct LogState
Expand Down
4 changes: 2 additions & 2 deletions stdlib/Logging/src/ConsoleLogger.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ function showvalue(io, e::Tuple{Exception,Any})
end
showvalue(io, ex::Exception) = showerror(io, ex)

function default_logcolor(level)
function default_logcolor(level::LogLevel)
level < Info ? Base.debug_color() :
level < Warn ? Base.info_color() :
level < Error ? Base.warn_color() :
Base.error_color()
end

function default_metafmt(level, _module, group, id, file, line)
function default_metafmt(level::LogLevel, _module, group, id, file, line)
@nospecialize
color = default_logcolor(level)
prefix = (level == Warn ? "Warning" : string(level))*':'
Expand Down

0 comments on commit c67d810

Please sign in to comment.