beetbox / beetbox/beets

Beets logging overhaul

Open
#6,553 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
15.7k
Forks
2.1k
Avg merge
4d 21h
Merged PRs (30d)
31

Description

**Goal**: Replace current messy logging setup with flexible, config-driven system using Python's `logging.config.dictConfig()` or similar. Also fix a number of issues with the current logging setup.

## Idea

Create a **comprehensive, config-driven logging system** that replaces our current messy setup. My idea would be to inline the logging config into beets' main `config.yaml`, add predefined modes like `minimal` (current), `verbose` (debug+timestamps+file refs for bug reports), and support fully custom user-defined configurations via Python's dictConfig schema.

This could for example look like this:

```yaml
# --------------- Logging --------------

verbose: 0
logging:
mode: minimal

modes:
minimal:
...
debug:
version: 1
formatters:
default:
format: "%(asctime)s | %(levelname)-8s | %(process)d:%(threadName)s | %(name)s:%(lineno)d | %(message)s"
handlers:
stdout:
class: logging.StreamHandler
formatter: default
loggers:
beets:
level: DEBUG
handlers: [stdout]
propagate: false
beetsplug:
level: DEBUG
handlers: [stdout]
propagate: false
root:
level: DEBUG
handlers: [stdout]
```

## Other (related issues)

Maybe we can split these of and fix them first before we start with refactoring the logging system. Ordered by assumed difficulty.

- [x] **Test helper**: Remove custom `capture_log` and use pytest `caplog` instead
- #6595
- #6618
- #6617
- #6659
- #6638
- #6677
- #6678
- #6680
- #6739
- [x] **Plugin name prefixing**: We currently use ad-hoc string manipulation for the plugin name instead of proper `logging.Formatter`. This adds quite a bit of unnecessary logic.
- #6593
- [x] **Import side-effects**: logging setup happens during imports (breaks test isolation + plugin order + package use)
- #6755
- [ ] **Multiple verbose flags**: CLI + global config + per-plugin without clear precedence (`-v`). also `--quite` flag for some plugins. This needs a guide and maybe some rethinking.
- [ ] **Inconsistent UI vs logging**: beets uses both `ui.print()` for user messages and the `logging` system inconsistently for feedback. We might profit from defining guidelines when which should be used.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing beets' current logging setup and the related issues listed in the body, especially the pytest caplog migration and import-side-effect work. Define the scope and precedence for verbose flags, UI messages, predefined modes, and custom dictConfig before implementation; done should include a documented, config-driven logging system with consistent behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, observability
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.