Feature Request: Configurable log level for 'mail.log' logger (e.g., via environment variable or Controller parameter)
- 主要言語
- Python
- スター
- 373
- フォーク
- 105
- 平均マージ
- 4分
- マージ済み PR(30日)
- 2
説明
**### Feature Request: Make 'mail.log' protocol logging level configurable**
**Current Behavior**
Many SMTP protocol events in aiosmtpd are hard-coded to log at **INFO** level using the `mail.log` logger, including:
- Available AUTH mechanisms
- Peer connection details (`Peer: ...`)
- Connection handling
- Incoming commands (`>> b'HELO ...'`, `>> b'MAIL FROM:...'`, etc.)
- Sender/recipient extraction (`sender: ...`, `recip: ...`)
Finer details (e.g., raw server responses `<< b'250 ...'`, DATA chunks) are at **DEBUG** level.
This means these protocol events are always visible at INFO, even in production deployments where quieter logs are preferred. The standalone `aiosmtpd` CLI supports a `--debug` / `-d` flag that adjusts the `mail.log` level (INFO for one `-d`, DEBUG for two), but when using the library programmatically via `Controller`, there is no equivalent way to control this.
**Requested Change**
Add a simple way to configure the base log level for the `mail.log` logger when embedding aiosmtpd, such as:
- An environment variable (e.g., `AIOSMTPD_LOG_LEVEL=INFO|DEBUG|WARNING`)
- A parameter on `Controller` (e.g., `log_level=logging.INFO`)
- Or expose the logger instance for user configuration before starting the server
This would allow downstream projects (like Mailrise, custom relays, etc.) to run with minimal INFO noise in normal operation while still enabling full DEBUG tracing when needed.
**Use Case**
In containerized deployments (e.g., Docker), users often want clean logs by default but verbose protocol traces for troubleshooting. Currently, the only workaround is manual logging configuration in code or external log filtering, which isn't ideal for library users.
**Additional Context**
- No existing issues appear to cover this specific request.
- The CLI already implements similar logic in `main.py` by adjusting `logging.getLogger("mail.log").setLevel(...)` based on debug count.
- This would align with other configurable aspects (e.g., `AIOSMTPD_CONTROLLER_TIMEOUT` env var).
Thanks for considering this enhancement!
Cheers and Happy New Year
コントリビューションガイド
評価
この issue はまだ評価されていません。