Skip to content

Commit

Permalink
More cautious legacy_color conversion in Logging
Browse files Browse the repository at this point in the history
While the original line

    color = StyledStrings.Face(foreground=StyledStrings.Legacy.legacy_color(color))

does a perfectly adequate job of mapping old color names to
`SimpleColor`s, it neglects the newer capability of using named `Faces`
with logging.

It is better to first check that the value of `color` can indeed be
recognised as a `legacy_color`-compatible named color, before using it
as the foreground value.
  • Loading branch information
tecosaur committed Feb 12, 2024
1 parent af90dac commit d222762
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion stdlib/Logging/src/ConsoleLogger.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ function handle_message(logger::ConsoleLogger, level::LogLevel, message, _module
# Format lines as text with appropriate indentation and with a box
# decoration on the left.
color, prefix, suffix = logger.meta_formatter(level, _module, group, id, filepath, line)::Tuple{Union{Symbol,Int},String,String}
color = StyledStrings.Face(foreground=StyledStrings.Legacy.legacy_color(color))
lcolor = StyledStrings.Legacy.legacy_color(color)
if !isnothing(lcolor)
color = StyledStrings.Face(foreground=lcolor)
end
minsuffixpad = 2
buf = IOBuffer()
iob = IOContext(buf, stream)
Expand Down

0 comments on commit d222762

Please sign in to comment.