Skip to content

Log refactor formatter#6593

Open
semohr wants to merge 2 commits intomasterfrom
log_refactor_formatter
Open

Log refactor formatter#6593
semohr wants to merge 2 commits intomasterfrom
log_refactor_formatter

Conversation

@semohr
Copy link
Copy Markdown
Contributor

@semohr semohr commented Apr 30, 2026

This pull request refactors how log messages are formatted in the codebase, specifically replacing the use of a logging filter with a custom logging formatter to append plugin names to log messages. This change improves flexibility and future extensibility for logging setups.

This is part of the multi-step efforts to improve logging in beets #6553


This change should yield no visible change for users and is entirely a internal refactor:

musicbrainz: Searching for '' with {'release': 'somebody that i used to know', 'arid': '89ad4ac3-39f7-470e-963a-56509c546377'}
Searching for MusicBrainz releases with: 'release:(somebody that i used to know) arid:(89ad4ac3\\-39f7\\-470e\\-963a\\-56509c546377)'
musicbrainz: Found 5 result(s)
musicbrainz: Requesting MusicBrainz release 7841a24b-02fc-437e-a146-e59de916f1a2

Copilot AI review requested due to automatic review settings April 30, 2026 08:53
@semohr semohr requested a review from a team as a code owner April 30, 2026 08:53
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

⚠️ Unsupported file format

Upload processing failed due to unsupported file format. Please review the parser error message:
Error parsing JUnit XML in /home/runner/work/beets/beets/.reports/pytest.xml at 13:12132

Caused by:
RuntimeError: Error converting computed name to ValidatedString

Caused by:
    string is too long</code></pre>

For more help, visit our troubleshooting guide.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

PR move plugin-name prefixing in logs from logging.Filter into custom logging.Formatter, so logging setup can grow into future config-driven format.

Changes:

  • Remove PluginLogFilter from plugin logger setup.
  • Add LegacyFormatter and set it on default beets UI stream handler to build musicbrainz: msg style output.
  • Note internal refactor in changelog.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
docs/changelog.rst Document switch from filter-based to formatter-based plugin prefixing.
beets/ui/init.py Default beets logger handler now uses LegacyFormatter("%(legacy_msg)s").
beets/plugins.py Stop attaching per-plugin PluginLogFilter to plugin child loggers.
beets/logging.py Introduce LegacyFormatter that builds legacy_msg from child logger name + message.

Comment thread beets/plugins.py
Comment thread beets/logging.py Outdated
Comment thread beets/logging.py
@semohr
Copy link
Copy Markdown
Contributor Author

semohr commented Apr 30, 2026

Current test failures are expected as the caplog setup we use currently in testing does not capture the formatting correctly.

@semohr semohr force-pushed the log_refactor_formatter branch from bf9ff64 to 83c1867 Compare April 30, 2026 09:08
Comment thread beets/logging.py
@snejus
Copy link
Copy Markdown
Member

snejus commented Apr 30, 2026

Current test failures are expected as the caplog setup we use currently in testing does not capture the formatting correctly.

I guess you want to rebase this on the branch that fixes the caplog setup?

@semohr
Copy link
Copy Markdown
Contributor Author

semohr commented Apr 30, 2026

I guess you want to rebase this on the branch that fixes the caplog setup?

Yeah that was my idea. I did not want to fixup the capture_log contextmanager to just remove it again two PRs down the line.

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.

3 participants