@@ -12,10 +12,10 @@ Log levels less than `min_level` are filtered out.
1212Message formatting can be controlled by setting keyword arguments:
1313
1414* `meta_formatter` is a function which takes the log event metadata
15- `(level, _module, group, id, file, line)` and returns a color (as would be
16- passed to printstyled) , prefix and suffix for the log message. The
17- default is to prefix with the log level and a suffix containing the module,
18- file and line location.
15+ `(level, _module, group, id, file, line)` and returns a face name (used in
16+ the constructed [`AnnotatedString`](@ref Base.AnnotatedString)) , prefix and
17+ suffix for the log message. The default is to prefix with the log level and
18+ a suffix containing the module, file and line location.
1919* `show_limited` limits the printing of large data structures to something
2020 which can fit on the screen by setting the `:limit` `IOContext` key during
2121 formatting.
@@ -59,10 +59,10 @@ showvalue(io, ex::Exception) = showerror(io, ex)
5959
6060function default_logcolor (level:: LogLevel )
6161 level in keys (custom_log_levels) ? custom_log_levels[level][2 ] :
62- level < Info ? Base . debug_color () :
63- level < Warn ? Base . info_color () :
64- level < Error ? Base . warn_color () :
65- Base . error_color ()
62+ level < Info ? :log_debug :
63+ level < Warn ? :log_info :
64+ level < Error ? :log_warn :
65+ :log_error
6666end
6767
6868function default_metafmt (level:: LogLevel , _module, group, id, file, line)
@@ -104,6 +104,8 @@ function termlength(str)
104104 return N
105105end
106106
107+ termlength (str:: Base.AnnotatedString ) = textwidth (str)
108+
107109function handle_message (logger:: ConsoleLogger , level:: LogLevel , message, _module, group, id,
108110 filepath, line; kwargs... )
109111 @nospecialize
@@ -146,6 +148,7 @@ function handle_message(logger::ConsoleLogger, level::LogLevel, message, _module
146148 # Format lines as text with appropriate indentation and with a box
147149 # decoration on the left.
148150 color, prefix, suffix = logger. meta_formatter (level, _module, group, id, filepath, line):: Tuple{Union{Symbol,Int},String,String}
151+ color = Face (foreground= StyledStrings. Legacy. legacy_color (color))
149152 minsuffixpad = 2
150153 buf = IOBuffer ()
151154 iob = IOContext (buf, stream)
@@ -159,19 +162,19 @@ function handle_message(logger::ConsoleLogger, level::LogLevel, message, _module
159162 nonpadwidth = 2 + length (suffix)
160163 end
161164 for (i, (indent, msg)) in enumerate (msglines)
162- boxstr = length (msglines) == 1 ? " [ " :
163- i == 1 ? " ┌ " :
164- i < length (msglines) ? " │ " :
165- " └ "
166- printstyled (iob, boxstr, bold= true , color = color )
165+ boxstr = length (msglines) == 1 ? " [" :
166+ i == 1 ? " ┌" :
167+ i < length (msglines) ? " │" :
168+ " └"
169+ print (iob, styled " {$color, bold:$boxstr} " )
167170 if i == 1 && ! isempty (prefix)
168- printstyled (iob, prefix, " " , bold= true , color = color )
171+ print (iob, styled " {$color, bold:$prefix} " )
169172 end
170173 print (iob, " " ^ indent, msg)
171174 if i == length (msglines) && ! isempty (suffix)
172175 npad = max (0 , justify_width - nonpadwidth) + minsuffixpad
173176 print (iob, " " ^ npad)
174- printstyled (iob, suffix, color = :light_black )
177+ print (iob, styled " {shadow:$suffix} " )
175178 end
176179 println (iob)
177180 end
0 commit comments