Skip to content

Commit

Permalink
Merge pull request #11 from psrenergy/gb/add-close-logger
Browse files Browse the repository at this point in the history
Add new function to close logger
  • Loading branch information
guilhermebodin authored Jun 20, 2024
2 parents 7de6df6 + d421bd9 commit 122f968
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

2 comments on commit 122f968

@guilhermebodin
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/109434

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.2 -m "<description of version>" 122f968cfe25280756cbd5b813e0818dccc929f5
git push origin v0.3.2

Please sign in to comment.