@@ -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.
@@ -59,10 +59,10 @@ showvalue(io, ex::Exception) = showerror(io, ex)
59
59
60
60
function default_logcolor (level:: LogLevel )
61
61
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
66
66
end
67
67
68
68
function default_metafmt (level:: LogLevel , _module, group, id, file, line)
@@ -104,6 +104,8 @@ function termlength(str)
104
104
return N
105
105
end
106
106
107
+ termlength (str:: Base.AnnotatedString ) = textwidth (str)
108
+
107
109
function handle_message (logger:: ConsoleLogger , level:: LogLevel , message, _module, group, id,
108
110
filepath, line; kwargs... )
109
111
@nospecialize
@@ -146,6 +148,7 @@ function handle_message(logger::ConsoleLogger, level::LogLevel, message, _module
146
148
# Format lines as text with appropriate indentation and with a box
147
149
# decoration on the left.
148
150
color, prefix, suffix = logger. meta_formatter (level, _module, group, id, filepath, line):: Tuple{Union{Symbol,Int},String,String}
151
+ color = StyledStrings. Face (foreground= StyledStrings. Legacy. legacy_color (color))
149
152
minsuffixpad = 2
150
153
buf = IOBuffer ()
151
154
iob = IOContext (buf, stream)
@@ -159,19 +162,19 @@ function handle_message(logger::ConsoleLogger, level::LogLevel, message, _module
159
162
nonpadwidth = 2 + length (suffix)
160
163
end
161
164
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} " )
167
170
if i == 1 && ! isempty (prefix)
168
- printstyled (iob, prefix, " " , bold= true , color = color )
171
+ print (iob, styled " {$color, bold:$prefix} " )
169
172
end
170
173
print (iob, " " ^ indent, msg)
171
174
if i == length (msglines) && ! isempty (suffix)
172
175
npad = max (0 , justify_width - nonpadwidth) + minsuffixpad
173
176
print (iob, " " ^ npad)
174
- printstyled (iob, suffix, color = :light_black )
177
+ print (iob, styled " {shadow:$suffix} " )
175
178
end
176
179
println (iob)
177
180
end
0 commit comments