dockerflow.logging.JsonLogFormatter should handle dates better
還沒有人認領這個 Issue。
評估
研究方向
Start with the JsonLogFormatter in the dockerflow.logging module, where json.dumps is called and the default encoder is used. The issue proposes a combined encoder that falls back to repr() for unknown objects and handles datetimes. Done means datetime values log as ISO strings and a test confirms the output. The issue is over nine years old with no linked pull request, so check the current code before starting.
由索引模型根據 Issue 內容生成。
描述
https://github.com/mozilla-services/python-dockerflow/issues/8 fixes the exception that can happen when you log objects. What'd be even nicer, as @jezdez pointed out, would be to handle datetimes/dates : currently they are serialized as "datetime.datetime(2017, 4, 6, 9, 27, 7, 479427)" because that's the repr() for a datetime object, but we could do better by using DjangoJSONEncoder, which knows how to handle those objects and more.
Something like this should work, to test:
class SafeJSONEncoder(json.JSONEncoder):
def default(self, o):
return repr(o)
class SafeDjangoJSONEncoder(DjangoJSONEncoder, SafeJSONEncoder):
pass
Then use cls=SafeDjangoJSONEncoder when doing the json.dumps.
- 主要語言
- 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
-
難度 2/5 1-3 小時 新手友好度 72/100
huggingface/sentence-transformers#4186 ·
維護者通常 5 天內回覆
-
documentation
難度 1/5 1 小時以內 新手友好度 92/100
QuantEcon/QuantEcon.py#988 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
fabriziosalmi/certmate#1247 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
-
documentation good first issue
難度 2/5 半天 新手友好度 72/100
sujithputta02/Esapay#13 ·