Skip to content

fix: leave logging configuration to the importing application - #76

Merged
jm-rivera merged 4 commits into
mainfrom
fix/68-leave-logging-to-application
Oct 27, 2026
Merged

jm-rivera merged 4 commits into
mainfrom
fix/68-leave-logging-to-application

Conversation

@tillywoodfield

@tillywoodfield tillywoodfield commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #68

Importing oda_reader called logging.basicConfig(level=logging.INFO, ...) in oda_reader/common.py, which gave the host application a root handler, an INFO level and oda_reader's format, and turned the application's own later basicConfig into a no-op. That call is gone. Every module logs through logging.getLogger(__name__), so all of the package's messages sit under oda_reader with no handler or level set, and an unconfigured application sees only warnings and errors.

The oda_importer name keeps working until 2.0 through oda_reader/_logging.py. On import, the package takes the oda_importer logger, swaps its class to one whose setLevel, addHandler and addFilter raise a DeprecationWarning once per process, and makes it the parent of the oda_reader logger. Levels, handlers and propagate = False set on oda_importer then reach every package record through the normal parent walk, and this works whether the application configures oda_importer before or after the import. A level, handler or filter already on oda_importer when the package is imported triggers the same warning. The public oda_reader.common.logger is that same oda_importer logger, so code that configured it keeps the same reach, and the install step clears the logging manager's level caches so a level evaluated before the import doesn't go stale. Registering the package logger object under the old name, as dcp-tools did, gives no warning, and a dictConfig that names only oda_reader (with the default disable_existing_loggers) then disables the package logger through the alias key. The test for that case fails under the alias approach.

Three uses of oda_importer stop affecting the package, and the changelog says so. A dictConfig or fileConfig that names oda_importer with the default disable_existing_loggers disables the oda_reader.* module loggers, because they are not its children by name. Setting .disabled on it, or adding a logger-level filter, has no effect, because logger filters run only on the logger that creates the record. The class swap is the part to check most closely.

docs/docs/advanced.md gains an "Enable logging" section on turning the package's logging up or down, replacing the claim that it had no logging. The release is 1.13.0, since it deprecates a public logger name, with the changelog showing how to turn INFO messages back on.

Testing: ruff check, ruff format --check, ty check and the unit suite (pytest -n auto -m "not integration", 687 passed, 8 skipped) ran locally on Python 3.13, and CI passed on all nine OS and Python combinations. The new tests/common/unit/test_logging.py runs import-state, dictConfig and configured-before-import cases in fresh interpreters. Restoring the basicConfig line fails the import test, and swapping in the dcp-tools alias fails the dictConfig test. Over repeated runs, test_register_bulk_file.py::TestOfflineRead::test_online_hit_records_dataset_for_offline_reads failed once in about fifteen, finding more than one bulk-cache record. That file and the cache logic it exercises are untouched here.

🤖 Generated with Claude Code

@tillywoodfield

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T13:16:11.883431Z 80f861d Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf688ba8e3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/oda_reader/_logging.py Resolved
@tillywoodfield

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5b3b6500df

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/oda_reader/common.py Resolved
@tillywoodfield

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 80f861dd99

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@tillywoodfield
tillywoodfield marked this pull request as ready for review October 27, 2026 13:14

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 80f861dd99

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/oda_reader/_logging.py Resolved

@jm-rivera jm-rivera left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @tillywoodfield just a comment on version

Comment thread pyproject.toml Resolved
…1.13.0

install_legacy_logger_name() now emits the DeprecationWarning when the
oda_importer logger already has a level, handler or filter, so a
configuration made before importing oda_reader warns as well. The
release becomes 1.13.0, since it deprecates a public logger name.

@jm-rivera jm-rivera left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved. I pushed de10272: the release is now 1.13.0, since it deprecates a public logger name, and install_legacy_logger_name() warns when oda_importer already has a level, handler or filter at import, so the changelog holds for configuration made before the import too.

@jm-rivera
jm-rivera merged commit a17ac19 into main Oct 27, 2026
10 checks passed
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.

Stop oda_reader.common configuring the root logger at import

2 participants