diff --git a/Project.toml b/Project.toml index 50b3a7b..3a8cbb3 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "LoggingPolyglot" uuid = "211639cc-9b11-4cfd-abc6-8f7477829344" -version = "0.3.1" +version = "0.3.2" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" diff --git a/src/logger.jl b/src/logger.jl index 7f8dd2f..d38c474 100644 --- a/src/logger.jl +++ b/src/logger.jl @@ -12,6 +12,19 @@ function close_polyglot_logger(logger::TeeLogger) return nothing end +""" + close_polyglot_logger() + +Calls [`close_polyglot_logger(logger::TeeLogger)`](@ref) if `global_logger()` is a `TeeLogger` +""" +function close_polyglot_logger() + logger = Logging.global_logger() + if logger isa LoggingExtras.TeeLogger + close_polyglot_logger(logger) + end + return nothing +end + """ remove_log_file_path_on_logger_creation(path::AbstractString) diff --git a/src/logs.jl b/src/logs.jl index 51d059f..a66beab 100644 --- a/src/logs.jl +++ b/src/logs.jl @@ -31,10 +31,7 @@ function fatal_error( ) @logmsg FATAL_ERROR_LEVEL msg - logger = Logging.global_logger() - if logger isa LoggingExtras.TeeLogger - close_polyglot_logger(logger) - end + close_polyglot_logger() throw(exception) return nothing end