-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathlogformat.jl
27 lines (25 loc) · 944 Bytes
/
logformat.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# This is run multiple times during testing,
# for simpler running of individual tests.
function custom_metafmt(level, _module, group, id, file, line)
color = WebSockets.default_logcolor(level)
prefix = string(level) * ':'
suffix = " $(Int(round((Dates.now() - T0_TESTS).value / 1000))) s @"
_module !== nothing && (suffix *= "$(_module)")
if file !== nothing
_module !== nothing && (suffix *= " ")
suffix *= Base.contractuser(file)
if line !== nothing
suffix *= ":$(isa(line, UnitRange) ? "$(first(line))-$(last(line))" : line)"
end
end
return color, prefix, suffix
end
if !@isdefined OLDLOGGER
const OLDLOGGER = WebSockets.global_logger()
const T0_TESTS = Dates.now()
end
if !@isdefined TESTLOGR
const TESTLOGR = WebSockets.WebSocketLogger(stderr, Base.CoreLogging.Debug, meta_formatter = custom_metafmt)
WebSockets.global_logger(TESTLOGR)
end
nothing