Skip to content

REF: Remove LoggingExtras and use a package-local logger instead of global#490

Open
odow wants to merge 2 commits intolanl-ansi:mainfrom
odow:od/logging
Open

REF: Remove LoggingExtras and use a package-local logger instead of global#490
odow wants to merge 2 commits intolanl-ansi:mainfrom
odow:od/logging

Conversation

@odow
Copy link
Copy Markdown
Contributor

@odow odow commented Apr 14, 2026

I am migrating the InfrastructureModels ecosystem away from Memento.jl.

See lanl-ansi/InfrastructureModels.jl#99

PMD made this change a number of years ago. Your current design has a number of unforeseen consequences.

There are two main issues. The first is that this function mutates global state. If someone changes the logger after PMD, this function will erase their changes back to the global state before PMD.

function restore_global_logger!()
Logging.global_logger(_DEFAULT_LOGGER)

The other issue (or feature, depending on how you see it) is that every log must go through the PMD logger, even if they're completely unrelated.

LoggingExtras.EarlyFilteredLogger(_LOGGER) do log
if log._module == PowerModelsDistribution && log.level < level
return false
else
return true

These aren't the end of the world (it's only logging), so merging this PR isn't strictly necessary. I mainly made this PR as an exercise to check that our logging strategy also works for PMD.

test_log

There's one issue with my design: @test_logs works by replacing the global logger with something that caches the logs so it can parse them for the messages. Since we have a package-specific logger we need our own version of _test_logs.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 38.93805% with 69 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.22%. Comparing base (79874bc) to head (e4ca9ac).

Files with missing lines Patch % Lines
src/core/data.jl 5.26% 18 Missing ⚠️
src/data_model/transformations/rawdss2dss.jl 14.28% 12 Missing ⚠️
src/core/constraint_template.jl 0.00% 5 Missing ⚠️
src/data_model/multinetwork.jl 16.66% 5 Missing ⚠️
src/core/logging.jl 82.35% 3 Missing ⚠️
src/data_model/base/parse.jl 40.00% 3 Missing ⚠️
src/form/en_ivr.jl 0.00% 3 Missing ⚠️
src/io/json/json.jl 0.00% 3 Missing ⚠️
src/io/utils.jl 62.50% 3 Missing ⚠️
src/data_model/transformations/eng2math.jl 0.00% 2 Missing ⚠️
... and 10 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #490      +/-   ##
==========================================
+ Coverage   74.09%   74.22%   +0.12%     
==========================================
  Files          73       73              
  Lines       16404    16425      +21     
==========================================
+ Hits        12155    12191      +36     
+ Misses       4249     4234      -15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant