Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new function to close logger #11

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading