|
1 | 1 | # This file is a part of Julia. License is MIT: https://julialang.org/license
|
2 | 2 |
|
3 |
| -using Logging |
4 |
| -import Logging: Info, |
5 |
| - shouldlog, handle_message, min_enabled_level, catch_exceptions |
| 3 | +using Logging: Logging, AbstractLogger, LogLevel, Info, with_logger |
6 | 4 | import Base: occursin
|
7 | 5 |
|
8 | 6 | #-------------------------------------------------------------------------------
|
@@ -30,22 +28,23 @@ mutable struct TestLogger <: AbstractLogger
|
30 | 28 | shouldlog_args
|
31 | 29 | end
|
32 | 30 |
|
33 |
| -TestLogger(; min_level=Info, catch_exceptions=false) = TestLogger(LogRecord[], min_level, catch_exceptions, nothing) |
34 |
| -min_enabled_level(logger::TestLogger) = logger.min_level |
| 31 | +TestLogger(; min_level=Info, catch_exceptions=false) = |
| 32 | + TestLogger(LogRecord[], min_level, catch_exceptions, nothing) |
| 33 | +Logging.min_enabled_level(logger::TestLogger) = logger.min_level |
35 | 34 |
|
36 |
| -function shouldlog(logger::TestLogger, level, _module, group, id) |
| 35 | +function Logging.shouldlog(logger::TestLogger, level, _module, group, id) |
37 | 36 | logger.shouldlog_args = (level, _module, group, id)
|
38 | 37 | true
|
39 | 38 | end
|
40 | 39 |
|
41 |
| -function handle_message(logger::TestLogger, level, msg, _module, |
42 |
| - group, id, file, line; kwargs...) |
| 40 | +function Logging.handle_message(logger::TestLogger, level, msg, _module, |
| 41 | + group, id, file, line; kwargs...) |
43 | 42 | @nospecialize
|
44 | 43 | push!(logger.logs, LogRecord(level, msg, _module, group, id, file, line, kwargs))
|
45 | 44 | end
|
46 | 45 |
|
47 | 46 | # Catch exceptions for the test logger only if specified
|
48 |
| -catch_exceptions(logger::TestLogger) = logger.catch_exceptions |
| 47 | +Logging.catch_exceptions(logger::TestLogger) = logger.catch_exceptions |
49 | 48 |
|
50 | 49 | function collect_test_logs(f; kwargs...)
|
51 | 50 | logger = TestLogger(; kwargs...)
|
|
0 commit comments