liblogging 0.2.3__tar.gz → 0.2.4__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: liblogging
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: Utilities for logging and sending logs.
5
5
  Home-page: https://github.com/XoriieInpottn/liblogging
6
6
  Author: xi
@@ -10,7 +10,6 @@ import json
10
10
  from datetime import datetime
11
11
  import time
12
12
 
13
- from .kafka_service import KafkaServiceFactory
14
13
  from ..util import split_trace_id, thread_pool_manager
15
14
 
16
15
 
@@ -26,11 +25,13 @@ def process_message(line):
26
25
  trace_id = message.get("trace_id", "")
27
26
  if trace_id:
28
27
  _, chat_dict = split_trace_id(trace_id)
29
- message.update({
30
- "uid": chat_dict.get("uid", ""),
31
- "session_id": chat_dict.get("session_id", ""),
32
- "turn": chat_dict.get("turn", 0)
33
- })
28
+ # 新日志直接携带 uid/session_id/turn;旧日志仍可从复合 trace_id
29
+ # 中解析。显式传入的非空字段始终优先,避免被兼容逻辑覆盖。
30
+ for field in ("uid", "session_id", "turn"):
31
+ if message.get(field) in (None, ""):
32
+ legacy_value = chat_dict.get(field)
33
+ if legacy_value is not None and legacy_value != "":
34
+ message[field] = legacy_value
34
35
  create_time = message.get("create_time")
35
36
  message.update({"create_date": get_date_from_time(create_time)})
36
37
  return trace_id, message
@@ -39,6 +40,8 @@ def process_message(line):
39
40
  class LogCollector:
40
41
 
41
42
  def __init__(self, args):
43
+ from .kafka_service import KafkaServiceFactory
44
+
42
45
  start_time = time.time()
43
46
  self.kafka_service = KafkaServiceFactory.create_kafka_service(
44
47
  config_path=args.config_path,
@@ -110,4 +113,4 @@ def main():
110
113
 
111
114
 
112
115
  if __name__ == "__main__":
113
- raise SystemExit(main())
116
+ raise SystemExit(main())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: liblogging
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: Utilities for logging and sending logs.
5
5
  Home-page: https://github.com/XoriieInpottn/liblogging
6
6
  Author: xi
@@ -20,7 +20,7 @@ if __name__ == '__main__':
20
20
  "liblogging_mongo_collector = liblogging.collector.mongo:main"
21
21
  ]
22
22
  },
23
- version='0.2.3',
23
+ version='0.2.4',
24
24
  description='Utilities for logging and sending logs.',
25
25
  long_description_content_type='text/markdown',
26
26
  long_description=long_description,
File without changes
File without changes
File without changes