Skip to content

Commit

Permalink
Add new function to close logger
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermebodin committed Jun 20, 2024
1 parent 7de6df6 commit d421bd9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
13 changes: 13 additions & 0 deletions src/logger.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions src/logs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d421bd9

Please sign in to comment.