Define a logging convention
@benoit74 已经在做这个了。
开始于 2023年12月1日。
评估
这个 Issue 还没有评估数据。
描述
We have not yet formalized a policy around logging, and I think this is clearly missing. It looks like a kind of convention is proposed in https://github.com/openzim/python-scraperlib/blob/main/src/zimscraperlib/logging.py but I do not find it very versatile and forces quite a lot of stuff (verbose dependencies, logger level is DEBUG, ...). Plus it seems to be rarely used in fact (I rarely encountered this at least).
I've read https://docs.python.org/3/howto/logging.html and there are tons of good ideas and recommendations, and this should probably be the first decision: adhere to recommendations in this document.
There are still open topics in this documentation, for which I propose decisions or suggest discussions below. WDYT? Anything else?
Live logging configuration
In order to be as versatile as possible, the software we produce must not take much decision on what needs to be logged and what is useless.
Software must hence allow to configure logging either:
- by an environment variable named
LOGGING_LEVELwhose value is a log level which is set in the root handler - by an environment variable named
LOGGING_FILE_CONFIGwhose value is the path to a configuration in configuration file format.
It should also support configuration by an environment variable named LOGGING_YAML_CONFIG whose value is the path to a YAML configuration adhering to the configuration dictionary schema
While LOGGING_YAML_CONFIG is the preferred solution (most versatile and less verbose), this is optional because it forces the use of PyYAML to parse the configuration file (and we might want to not include this in all projects).
If multiple LOGGING_* environment variables are set, the precedence is LOGGING_YAML_CONFIG > LOGGING_FILE_CONFIG > LOGGING_LEVEL.
We do not recommend to continue to support older environment variables for backward compatibility, or at least they must have even less precedence than the LOGGING_* ones.
Software must provide a sensible default configuration, typically with a default dict_config embedded in the code.
Loggers
Each software and library must use a unique logger with a unique and easily identifiable name, such as the __name__ of their top-level package or module. They must not log directly to the root logger.
This is meant to help the software / library user configure the logging verbosity or handlers as they wish while maintaining simplicity. Using a unique logger per software and library is deemed sufficient and avoids by default logging configurations that rely too heavily on module names. Should a specific need arise (e.g. filter out one kind of very verbose logs), it is always possible to achieve this with custom filters based on pathname or log content for instant. Experience shows we are usually lazy to do this anyway and long logger names are in fact just clogging the logs.
- 主要语言
- Python
- 星标
- 1
- 派生
- 2
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
openzim/_python-bootstrap 的其他 Issue
-
bug
难度 1/5 1 小时以内 新手友好度 76/100
openzim/_python-bootstrap#57 ·
-
enhancement
openzim/_python-bootstrap#54 · 1 条评论 · 已指派 2 人 ·
-
question
openzim/_python-bootstrap#53 · 已指派 1 人 ·
-
enhancement
难度 3/5 1-2 天 新手友好度 25/100
openzim/_python-bootstrap#51 · 3 条评论 ·
-
enhancement
openzim/_python-bootstrap#48 · 已指派 2 人 ·
查看 openzim/_python-bootstrap 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
xinnan-tech/xiaozhi-fde-talk#263 ·
-
rules
难度 1/5 1 小时以内 新手友好度 90/100
-
难度 2/5 1-3 小时 新手友好度 70/100
huggingface/Repo2RLEnv#163 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 95/100
huggingface/sentence-transformers#4074 ·
-
comp/dashboard invalid P3
难度 2/5 1-3 小时 新手友好度 70/100
NousResearch/hermes-agent#121143 ·