dockerflow.logging.JsonLogFormatter is weird about %s style logging
還沒有人認領這個 Issue。
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 50/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- python
研究方向
The formatter is dockerflow.logging.JsonLogFormatter, so start in the dockerflow/logging.py module and find where it builds the msg field from the log record. The bug appears when the %s argument is not a string, such as a dict, so check whether the formatter uses the raw record.msg instead of the formatted message. Done means logger.info("Hi %s", {'name': 'Peter'}) puts the rendered text in Fields.msg.
由索引模型根據 Issue 內容生成。
描述
I have this config:
# Logging
LOGGING_USE_JSON = values.BooleanValue(True)
LOGGING_DEFAULT_LEVEL = values.Value("INFO")
@property
def LOGGING(self):
return {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"json": {
"()": "dockerflow.logging.JsonLogFormatter",
"logger_name": "buildhub",
},
"verbose": {"format": "%(levelname)s %(asctime)s %(name)s %(message)s"},
},
"handlers": {
"console": {
"level": self.LOGGING_DEFAULT_LEVEL,
"class": "logging.StreamHandler",
"formatter": ("json" if self.LOGGING_USE_JSON else "verbose"),
},
"sentry": {
"level": "ERROR",
"class": (
"raven.contrib.django.raven_compat.handlers" ".SentryHandler"
),
},
"null": {"class": "logging.NullHandler"},
},
"root": {"level": "INFO", "handlers": ["sentry", "console"]},
...
When I do:
In [1]: import logging
In [2]: logger = logging.getLogger("myproject")
In [3]: logger.info("Hi!")
{"Timestamp": 1541787363833421056, "Type": "myproject", "Logger": "buildhub", "Hostname": "MacBook-Pro-131.local", "EnvVersion": "2.0", "Severity": 6, "Pid": 68488, "Fields": {"msg": "Hi!"}}
In [4]: logger.info("Hi %s", "peter")
{"Timestamp": 1541787379742094080, "Type": "myproject", "Logger": "buildhub", "Hostname": "MacBook-Pro-131.local", "EnvVersion": "2.0", "Severity": 6, "Pid": 68488, "Fields": {"msg": "Hi peter"}}
In [5]: logger.info("Hi %s", {'name': 'Peter'})
{"Timestamp": 1541787416647823104, "Type": "myproject", "Logger": "buildhub", "Hostname": "MacBook-Pro-131.local", "EnvVersion": "2.0", "Severity": 6, "Pid": 68488, "Fields": {}}
Notice that when the param to logger.debug(template, THIS) isn't a string the final "msg" becomes empty ("Fields": {}).
- 主要語言
- Python
- 星號
- 41
- 分支
- 21
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
mozilla-services/python-dockerflow 的其他 Issue
-
難度 3/5 半天 新手友好度 15/100
mozilla-services/python-dockerflow#119 · 1 則留言 ·
-
難度 2/5 1 小時以內 新手友好度 15/100
mozilla-services/python-dockerflow#117 · 1 則留言 ·
-
難度 5/5 一週以上 新手友好度 15/100
mozilla-services/python-dockerflow#116 · 1 則留言 ·
-
難度 3/5 半天 新手友好度 62/100
-
難度 5/5 一週以上 新手友好度 12/100
查看 mozilla-services/python-dockerflow 的全部 Issue
相似的 Issue
-
[Bug]: Streamed /v1/chat/completions sends unredacted agent error text (keys) in the final chunk可能已有人在做 @rodricksz4h5 今天認領。 未關閉area/streaming comp/gateway P2 type/security
難度 2/5 1-3 小時 新手友好度 78/100
NousResearch/hermes-agent#138245 ·
維護者通常 1 天內回覆
-
[oblt-aw][autodoc] Update user onboarding guide for mandatory trigger CODEOWNERS step可能已有人在做 @github-actions 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 66/100
維護者通常 1 天內回覆
-
correction metadata
難度 2/5 1 小時以內 新手友好度 68/100
acl-org/acl-anthology#10378 · 1 則留言 ·
維護者通常 1 天內回覆
-
cloudtrail_multi_region_enabled_logging_management_events fails when the advanced event selector has a custom name可能已有人在做 @12YYCCYY16 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
prowler-cloud/prowler#13033 ·
維護者通常 1 天內回覆
-
enhancement
難度 1/5 1-3 小時 新手友好度 88/100
graygarbage/HermesKey#23 ·