invenia / Memento.jl

A flexible logging library for Julia
https://invenia.github.io/Memento.jl/latest
Other
87 stars 14 forks source link

Support forced re-registration #186

Closed rofinn closed 2 years ago

rofinn commented 2 years ago

Add an optional kwarg to support forced re-registration of loggers. This is useful in cases where you want/need to override the default registration of parent loggers.

Example)

module Parent

const LOGGER = getlogger(@__MODULE__)

# This line won't get called until after the Child module is loaded and a Logger("Parent") has been added.
# Adding `force=true` make sure that the `LOGGER` above is registered cause that's what we're 
# referencing in our code.
__init__() = Memento.register(LOGGER; force=true)

module Child

const LOGGER = getlogger(@__MODULE__)

# For convenience this also registers a parent logger for cases where a parent isn't explicitly needed by the package,
# but is helpful for configuration management.
__init__() = Memento.register(LOGGER)

end

end
codecov[bot] commented 2 years ago

Codecov Report

Merging #186 (1fc552b) into master (916ea2e) will not change coverage. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #186   +/-   ##
=======================================
  Coverage   98.26%   98.26%           
=======================================
  Files          14       14           
  Lines         404      404           
=======================================
  Hits          397      397           
  Misses          7        7           
Impacted Files Coverage Δ
src/loggers.jl 99.26% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 916ea2e...1fc552b. Read the comment docs.