sycommon-python-lib 0.2.7a3__py3-none-any.whl → 0.2.7a4__py3-none-any.whl
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.
- sycommon/logging/kafka_log.py +24 -16
- {sycommon_python_lib-0.2.7a3.dist-info → sycommon_python_lib-0.2.7a4.dist-info}/METADATA +1 -1
- {sycommon_python_lib-0.2.7a3.dist-info → sycommon_python_lib-0.2.7a4.dist-info}/RECORD +6 -6
- {sycommon_python_lib-0.2.7a3.dist-info → sycommon_python_lib-0.2.7a4.dist-info}/WHEEL +0 -0
- {sycommon_python_lib-0.2.7a3.dist-info → sycommon_python_lib-0.2.7a4.dist-info}/entry_points.txt +0 -0
- {sycommon_python_lib-0.2.7a3.dist-info → sycommon_python_lib-0.2.7a4.dist-info}/top_level.txt +0 -0
sycommon/logging/kafka_log.py
CHANGED
|
@@ -443,21 +443,25 @@ class SYLogger:
|
|
|
443
443
|
统一日志记录入口
|
|
444
444
|
修复:手动提取堆栈信息并写入 message,确保 Kafka 能收到
|
|
445
445
|
|
|
446
|
-
单条开关(enabled
|
|
447
|
-
- None
|
|
446
|
+
单条开关(enabled,由公开方法从 **kwargs 按名取出,隐式参数):
|
|
447
|
+
- None / 非布尔(默认):跟随全局 log.enabled。全局关 -> 静默(ERROR 除外)
|
|
448
448
|
- True:强制发出(即便全局 log.enabled=false,这一条也进 kafka)
|
|
449
|
-
- False
|
|
449
|
+
- False:强制静默(即便全局开/ERROR,这一条也丢)
|
|
450
|
+
|
|
451
|
+
之所以用隐式 kwargs 而非显式形参:老项目里已有 SYLogger.info(msg, exec=xxx) 等
|
|
452
|
+
任意写法,显式形参会与历史调用冲突;从 kwargs 按名取则完全兼容,无需逐项目排查。
|
|
450
453
|
|
|
451
454
|
注意:ERROR 级别无论全局开关如何都会进 kafka(KafkaSink.write 对 ERROR 放行),
|
|
452
|
-
此处的 enabled=None + 全局关 对 ERROR 不静默——仅在 enabled
|
|
455
|
+
此处的 enabled=None + 全局关 对 ERROR 不静默——仅在 enabled is False 时才压制。
|
|
453
456
|
"""
|
|
454
|
-
#
|
|
457
|
+
# 单条开关裁决:严格布尔判定,非布尔值(None/exec 等)一律跟随全局
|
|
455
458
|
if enabled is False:
|
|
456
459
|
return # 强制静默
|
|
457
460
|
|
|
458
461
|
global_on = _global_log_enabled()
|
|
459
462
|
# 跟随全局且全局关:非 ERROR 静默(ERROR 始终放行,交由 KafkaSink 处理)
|
|
460
|
-
if enabled is None
|
|
463
|
+
if (enabled is None or not isinstance(enabled, bool)) \
|
|
464
|
+
and not global_on and level != "ERROR":
|
|
461
465
|
return
|
|
462
466
|
|
|
463
467
|
# 序列化消息:dict/list 先脱敏(按字段名/子串/长度/总量裁剪),再转 JSON
|
|
@@ -511,22 +515,26 @@ class SYLogger:
|
|
|
511
515
|
if check_env_flag(['DEV_LOG']):
|
|
512
516
|
print(log_dict)
|
|
513
517
|
|
|
518
|
+
# enabled 采用「隐式参数」:不显式写入签名(保持 *args/**kwargs 与历史调用 100%
|
|
519
|
+
# 兼容),而是从 **kwargs 中按名取出。这样老项目里已有的 SYLogger.info(msg, exec=xxx)
|
|
520
|
+
# 等任意写法都不受影响,无需逐项目排查;新功能通过 SYLogger.info(msg, enabled=True)
|
|
521
|
+
# 触发。_log 内部用 `is True` / `is False` 严格判定,非布尔值回退为「跟随全局」。
|
|
514
522
|
@staticmethod
|
|
515
|
-
def info(msg: any, *args,
|
|
516
|
-
SYLogger._log(msg, "INFO", enabled)
|
|
523
|
+
def info(msg: any, *args, **kwargs):
|
|
524
|
+
SYLogger._log(msg, "INFO", kwargs.get("enabled"))
|
|
517
525
|
|
|
518
526
|
@staticmethod
|
|
519
|
-
def warning(msg: any, *args,
|
|
520
|
-
SYLogger._log(msg, "WARNING", enabled)
|
|
527
|
+
def warning(msg: any, *args, **kwargs):
|
|
528
|
+
SYLogger._log(msg, "WARNING", kwargs.get("enabled"))
|
|
521
529
|
|
|
522
530
|
@staticmethod
|
|
523
|
-
def debug(msg: any, *args,
|
|
524
|
-
SYLogger._log(msg, "DEBUG", enabled)
|
|
531
|
+
def debug(msg: any, *args, **kwargs):
|
|
532
|
+
SYLogger._log(msg, "DEBUG", kwargs.get("enabled"))
|
|
525
533
|
|
|
526
534
|
@staticmethod
|
|
527
|
-
def error(msg: any, *args,
|
|
528
|
-
SYLogger._log(msg, "ERROR", enabled)
|
|
535
|
+
def error(msg: any, *args, **kwargs):
|
|
536
|
+
SYLogger._log(msg, "ERROR", kwargs.get("enabled"))
|
|
529
537
|
|
|
530
538
|
@staticmethod
|
|
531
|
-
def exception(msg: any, *args,
|
|
532
|
-
SYLogger._log(msg, "ERROR", enabled)
|
|
539
|
+
def exception(msg: any, *args, **kwargs):
|
|
540
|
+
SYLogger._log(msg, "ERROR", kwargs.get("enabled"))
|
|
@@ -211,7 +211,7 @@ sycommon/llm/tiktoken_cache/9b5ad71b2ce5302211f9c61530b329a4922fc6a4,sha256=Ijkh
|
|
|
211
211
|
sycommon/llm/tiktoken_cache/fb374d419588a4632f3f557e76b4b70aebbca790,sha256=RGqVOMtsNI41FhINfAiwn1fDZJXirP_-WaW_iwz7Gi0,3613922
|
|
212
212
|
sycommon/logging/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
213
213
|
sycommon/logging/async_sql_logger.py,sha256=TIUAqK8_F9H7Graw00hNjEI3DJ1ZRo5fRUcnqaMZlbU,2187
|
|
214
|
-
sycommon/logging/kafka_log.py,sha256=
|
|
214
|
+
sycommon/logging/kafka_log.py,sha256=H_nnSQtCXalxUyKzpjpa_6iTp1brGRRhyQhXH5qEjd0,20656
|
|
215
215
|
sycommon/logging/log_masker.py,sha256=o4yE1rZ8f8a3xwTLV7TZvAt9nPB2IjacKCxoJspbhBM,12797
|
|
216
216
|
sycommon/logging/logger_levels.py,sha256=xJBzPV2H7GpEQggOIjyckEsA4yf6s4NpI9ckgO3xWKA,1154
|
|
217
217
|
sycommon/logging/logger_wrapper.py,sha256=TtzmGw_K5NjBGBq9Gjqtnh834izAv8TQwsOeL2fIbAI,481
|
|
@@ -301,8 +301,8 @@ sycommon/tools/syemail.py,sha256=BDFhgf7WDOQeTcjxJEQdu0dQhnHFPO_p3eI0-Ni3LhQ,561
|
|
|
301
301
|
sycommon/tools/timing.py,sha256=OiiE7P07lRoMzX9kzb8sZU9cDb0zNnqIlY5pWqHcnkY,2064
|
|
302
302
|
sycommon/xxljob/__init__.py,sha256=7eoBlQxv-B39IfRSCY2bkqdGYs1QRe1umAWd88VMEEM,86
|
|
303
303
|
sycommon/xxljob/xxljob_service.py,sha256=1yifwIBNGsCIxLnQjHKiBlbsigc_zvPH-dMTZcNxe-Q,7649
|
|
304
|
-
sycommon_python_lib-0.2.
|
|
305
|
-
sycommon_python_lib-0.2.
|
|
306
|
-
sycommon_python_lib-0.2.
|
|
307
|
-
sycommon_python_lib-0.2.
|
|
308
|
-
sycommon_python_lib-0.2.
|
|
304
|
+
sycommon_python_lib-0.2.7a4.dist-info/METADATA,sha256=uZ0e_w_up1416YQu001gfJPQu6CJMVseAeBRddj8Yck,7960
|
|
305
|
+
sycommon_python_lib-0.2.7a4.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
306
|
+
sycommon_python_lib-0.2.7a4.dist-info/entry_points.txt,sha256=gsR4SssKxDWjRU8ggidzNcdMXDPRSKRS7UaGyNP84Qg,92
|
|
307
|
+
sycommon_python_lib-0.2.7a4.dist-info/top_level.txt,sha256=RgphKrg7nJyZ7irJqbxFr-5H2LUYTvI7ivoWZH2hcD0,29
|
|
308
|
+
sycommon_python_lib-0.2.7a4.dist-info/RECORD,,
|
|
File without changes
|
{sycommon_python_lib-0.2.7a3.dist-info → sycommon_python_lib-0.2.7a4.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.7a3.dist-info → sycommon_python_lib-0.2.7a4.dist-info}/top_level.txt
RENAMED
|
File without changes
|