@@ -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 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.
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.
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 ? :log_debug :
62
- level < Warn ? :log_info :
63
- level < Error ? :log_warn :
64
- :log_error
61
+ level < Info ? Base . debug_color () :
62
+ level < Warn ? Base . info_color () :
63
+ level < Error ? Base . warn_color () :
64
+ Base . error_color ()
65
65
end
66
66
67
67
function default_metafmt (level:: LogLevel , _module, group, id, file, line)
@@ -103,8 +103,6 @@ function termlength(str)
103
103
return N
104
104
end
105
105
106
- termlength (str:: Base.AnnotatedString ) = textwidth (str)
107
-
108
106
function handle_message (logger:: ConsoleLogger , level:: LogLevel , message, _module, group, id,
109
107
filepath, line; kwargs... )
110
108
@nospecialize
@@ -156,7 +154,6 @@ function handle_message(logger::ConsoleLogger, level::LogLevel, message, _module
156
154
# Format lines as text with appropriate indentation and with a box
157
155
# decoration on the left.
158
156
color, prefix, suffix = logger. meta_formatter (level, _module, group, id, filepath, line):: Tuple{Union{Symbol,Int},String,String}
159
- color = StyledStrings. Face (foreground= StyledStrings. Legacy. legacy_color (color))
160
157
minsuffixpad = 2
161
158
buf = IOBuffer ()
162
159
iob = IOContext (buf, stream)
@@ -170,19 +167,19 @@ function handle_message(logger::ConsoleLogger, level::LogLevel, message, _module
170
167
nonpadwidth = 2 + length (suffix)
171
168
end
172
169
for (i, (indent, msg)) in enumerate (msglines)
173
- boxstr = length (msglines) == 1 ? " [" :
174
- i == 1 ? " ┌" :
175
- i < length (msglines) ? " │" :
176
- " └"
177
- print (iob, styled " {$color, bold:$boxstr} " )
170
+ boxstr = length (msglines) == 1 ? " [ " :
171
+ i == 1 ? " ┌ " :
172
+ i < length (msglines) ? " │ " :
173
+ " └ "
174
+ printstyled (iob, boxstr, bold= true , color = color )
178
175
if i == 1 && ! isempty (prefix)
179
- print (iob, styled " {$color, bold:$prefix} " )
176
+ printstyled (iob, prefix, " " , bold= true , color = color )
180
177
end
181
178
print (iob, " " ^ indent, msg)
182
179
if i == length (msglines) && ! isempty (suffix)
183
180
npad = max (0 , justify_width - nonpadwidth) + minsuffixpad
184
181
print (iob, " " ^ npad)
185
- print (iob, styled " {shadow:$ suffix} " )
182
+ printstyled (iob, suffix, color = :light_black )
186
183
end
187
184
println (iob)
188
185
end
0 commit comments