@@ -12,10 +12,10 @@ Log levels less than `min_level` are filtered out.
12
12
Message formatting can be controlled by setting keyword arguments:
13
13
14
14
* `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.
19
19
* `show_limited` limits the printing of large data structures to something
20
20
which can fit on the screen by setting the `:limit` `IOContext` key during
21
21
formatting.
58
58
showvalue (io, ex:: Exception ) = showerror (io, ex)
59
59
60
60
function default_logcolor (level:: LogLevel )
61
- level < Info ? Base . debug_color () :
62
- level < Warn ? Base . info_color () :
63
- level < Error ? Base . warn_color () :
64
- Base . error_color ()
61
+ level < Info ? :log_debug :
62
+ level < Warn ? :log_info :
63
+ level < Error ? :log_warn :
64
+ :log_error
65
65
end
66
66
67
67
function default_metafmt (level:: LogLevel , _module, group, id, file, line)
@@ -103,6 +103,8 @@ function termlength(str)
103
103
return N
104
104
end
105
105
106
+ termlength (str:: Base.AnnotatedString ) = textwidth (str)
107
+
106
108
function handle_message (logger:: ConsoleLogger , level:: LogLevel , message, _module, group, id,
107
109
filepath, line; kwargs... )
108
110
@nospecialize
@@ -145,6 +147,7 @@ function handle_message(logger::ConsoleLogger, level::LogLevel, message, _module
145
147
# Format lines as text with appropriate indentation and with a box
146
148
# decoration on the left.
147
149
color, prefix, suffix = logger. meta_formatter (level, _module, group, id, filepath, line):: Tuple{Union{Symbol,Int},String,String}
150
+ color = Face (foreground= StyledStrings. Legacy. legacy_color (color))
148
151
minsuffixpad = 2
149
152
buf = IOBuffer ()
150
153
iob = IOContext (buf, stream)
@@ -158,19 +161,19 @@ function handle_message(logger::ConsoleLogger, level::LogLevel, message, _module
158
161
nonpadwidth = 2 + length (suffix)
159
162
end
160
163
for (i, (indent, msg)) in enumerate (msglines)
161
- boxstr = length (msglines) == 1 ? " [ " :
162
- i == 1 ? " ┌ " :
163
- i < length (msglines) ? " │ " :
164
- " └ "
165
- printstyled (iob, boxstr, bold= true , color = color )
164
+ boxstr = length (msglines) == 1 ? " [" :
165
+ i == 1 ? " ┌" :
166
+ i < length (msglines) ? " │" :
167
+ " └"
168
+ print (iob, styled " {$color, bold:$boxstr} " )
166
169
if i == 1 && ! isempty (prefix)
167
- printstyled (iob, prefix, " " , bold= true , color = color )
170
+ print (iob, styled " {$color, bold:$prefix} " )
168
171
end
169
172
print (iob, " " ^ indent, msg)
170
173
if i == length (msglines) && ! isempty (suffix)
171
174
npad = max (0 , justify_width - nonpadwidth) + minsuffixpad
172
175
print (iob, " " ^ npad)
173
- printstyled (iob, suffix, color = :light_black )
176
+ print (iob, styled " {shadow:$suffix} " )
174
177
end
175
178
println (iob)
176
179
end
0 commit comments