Improve logging: named logger, rotation, richer format, remove use_log guards
- Add setup_logging() returning a named 'qbit-maid' logger with RotatingFileHandler (configurable size/backups) and a console handler - Add log_torrent() helper for structured torrent context - Replace basicConfig-based tor_log() with setup_logging() - Remove redundant 'if self.use_log:' guards across qbit-maid.py, qlist.py, qprocess.py, qlogging.py (level filtering handles it) - Document new logging options in config.toml.example and README
This commit is contained in:
1 parent
4416ebd924
commit
ab30d69c7c
6 files changed
+147
-65
No files matched your search
@@ -52,6 +52,9 @@ password = "pass"
|
||||
use_log = true
|
||||
log_level = "INFO"
|
||||
log_path = "./qc.log"
|
||||
# Optional: log rotation (defaults shown)
|
||||
log_max_bytes = 5000000
|
||||
log_backup_count = 3
|
||||
|
||||
[app_tags]
|
||||
protected_tag = "ipt"
|
||||
@@ -97,4 +100,22 @@ save = "save"
|
||||
[healthcheck]
|
||||
use_healthcheck = false
|
||||
healthcheck_url = "https://example.com/ping/<uuid>>"
|
||||
```
|
||||
|
||||
## Logging
|
||||
|
||||
qbit-maid uses a named logger (`qbit-maid`) that writes to both the configured
|
||||
log file and the console (useful for Docker/cron output).
|
||||
|
||||
- `use_log` — enable or disable logging entirely.
|
||||
- `log_level` — one of `DEBUG`, `INFO`, `WARN`, `ERROR`, `CRITICAL`.
|
||||
- `log_path` — path to the log file.
|
||||
- `log_max_bytes` — rotate the log file once it reaches this size (default 5 MB).
|
||||
- `log_backup_count` — number of rotated backups to keep (default 3).
|
||||
|
||||
Log lines include the timestamp, level, logger name, function, and line number,
|
||||
for example:
|
||||
|
||||
```
|
||||
10/26/2026 10:10:00 PM [INFO] qbit-maid:tor_processor:24 - Submitted ["My Torrent..."] for deletion.
|
||||
```
|
||||
Reference in new issue
Block a user