himile-python-log 0.4.0__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: himile_python_log
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Summary: A HIMILE utils package
5
5
  Author-email: qhw <20244111@himile.net>
6
6
  Requires-Python: >=3.10
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "himile_python_log"
7
- version = "0.4.0"
7
+ version = "0.5.0"
8
8
  authors = [{ name = "qhw", email = "20244111@himile.net" }]
9
9
  description = "A HIMILE utils package"
10
10
  readme = "README.md"
@@ -23,8 +23,12 @@ def get_trace_id() -> str:
23
23
 
24
24
 
25
25
  def _patch_record(record):
26
- """patcher: 自动将上下文中的 trace_id 注入 extra"""
26
+ """patcher: 自动将上下文中的 trace_id 注入 extra,并把多行消息压成单行。"""
27
27
  record["extra"]["trace_id"] = _trace_id_var.get()
28
+ # 将多行消息(如完整堆栈 Traceback、多行 error body)里的换行转义成 \n 字面量,
29
+ # 使每条日志始终只占一个物理行,便于按行采集/检索(ELK、Splunk 等见行即断)。
30
+ if isinstance(record.get("message"), str):
31
+ record["message"] = record["message"].replace("\r", "\\r").replace("\n", "\\n")
28
32
 
29
33
 
30
34
  class LogWrapper:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: himile_python_log
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Summary: A HIMILE utils package
5
5
  Author-email: qhw <20244111@himile.net>
6
6
  Requires-Python: >=3.10