sycommon-python-lib 0.1.26__py3-none-any.whl → 0.1.27__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.
Potentially problematic release.
This version of sycommon-python-lib might be problematic. Click here for more details.
- sycommon/logging/sql_logger.py +3 -7
- {sycommon_python_lib-0.1.26.dist-info → sycommon_python_lib-0.1.27.dist-info}/METADATA +1 -1
- {sycommon_python_lib-0.1.26.dist-info → sycommon_python_lib-0.1.27.dist-info}/RECORD +6 -6
- {sycommon_python_lib-0.1.26.dist-info → sycommon_python_lib-0.1.27.dist-info}/WHEEL +0 -0
- {sycommon_python_lib-0.1.26.dist-info → sycommon_python_lib-0.1.27.dist-info}/entry_points.txt +0 -0
- {sycommon_python_lib-0.1.26.dist-info → sycommon_python_lib-0.1.27.dist-info}/top_level.txt +0 -0
sycommon/logging/sql_logger.py
CHANGED
|
@@ -13,9 +13,9 @@ class SQLTraceLogger:
|
|
|
13
13
|
def serialize_params(params):
|
|
14
14
|
"""处理特殊类型参数的序列化"""
|
|
15
15
|
if isinstance(params, (list, tuple)):
|
|
16
|
-
return [
|
|
16
|
+
return [serialize_params(p) for p in params]
|
|
17
17
|
elif isinstance(params, dict):
|
|
18
|
-
return {k:
|
|
18
|
+
return {k: serialize_params(v) for k, v in params.items()}
|
|
19
19
|
elif isinstance(params, datetime):
|
|
20
20
|
return params.isoformat()
|
|
21
21
|
elif isinstance(params, Decimal):
|
|
@@ -29,12 +29,10 @@ class SQLTraceLogger:
|
|
|
29
29
|
conn, cursor, statement, parameters, context, executemany
|
|
30
30
|
):
|
|
31
31
|
try:
|
|
32
|
-
# 从连接的 execution_options 中获取开始时间
|
|
33
32
|
start_time = conn._execution_options.get(
|
|
34
33
|
"_start_time", time.time())
|
|
35
34
|
execution_time = (time.time() - start_time) * 1000
|
|
36
35
|
|
|
37
|
-
# 构建 SQL 日志信息
|
|
38
36
|
sql_log = {
|
|
39
37
|
"type": "SQL",
|
|
40
38
|
"statement": statement,
|
|
@@ -46,14 +44,12 @@ class SQLTraceLogger:
|
|
|
46
44
|
except Exception as e:
|
|
47
45
|
SYLogger.error(f"SQL日志处理失败: {str(e)}")
|
|
48
46
|
|
|
49
|
-
# 监听 SQL
|
|
47
|
+
# 监听 SQL 执行开始事件
|
|
50
48
|
@event.listens_for(Engine, "before_cursor_execute")
|
|
51
49
|
def before_cursor_execute(
|
|
52
50
|
conn, cursor, statement, parameters, context, executemany
|
|
53
51
|
):
|
|
54
52
|
try:
|
|
55
|
-
# 通过连接对象的 execution_options 设置开始时间
|
|
56
|
-
# 这里会创建一个新的执行选项副本,避免修改不可变对象
|
|
57
53
|
conn = conn.execution_options(_start_time=time.time())
|
|
58
54
|
except Exception as e:
|
|
59
55
|
SYLogger.error(f"SQL开始时间记录失败: {str(e)}")
|
|
@@ -17,7 +17,7 @@ sycommon/health/ping.py,sha256=FTlnIKk5y1mPfS1ZGOeT5IM_2udF5aqVLubEtuBp18M,250
|
|
|
17
17
|
sycommon/logging/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
18
|
sycommon/logging/kafka_log.py,sha256=3HjBg3WoDd3DmjtAlpyLcAVTKI-AHKrKlKmmPerq9tU,20751
|
|
19
19
|
sycommon/logging/logger_wrapper.py,sha256=TiHsrIIHiQMzXgXK12-0KIpU9GhwQJOoHslakzmq2zc,357
|
|
20
|
-
sycommon/logging/sql_logger.py,sha256=
|
|
20
|
+
sycommon/logging/sql_logger.py,sha256=s6mqGg3X1Srul8FQB-TJYGESigCrtnniuRq__Y6cFcY,2137
|
|
21
21
|
sycommon/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
22
|
sycommon/middleware/context.py,sha256=_5ghpv4u_yAvjkgM-XDx8OnO-YI1XtntHrXsHJHZkwo,88
|
|
23
23
|
sycommon/middleware/cors.py,sha256=0B5d_ovD56wcH9TfktRs88Q09R9f8Xx5h5ALWYvE8Iw,600
|
|
@@ -48,8 +48,8 @@ sycommon/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
48
48
|
sycommon/tools/docs.py,sha256=OPj2ETheuWjXLyaXtaZPbwmJKfJaYXV5s4XMVAUNrms,1607
|
|
49
49
|
sycommon/tools/snowflake.py,sha256=DdEj3T5r5OEvikp3puxqmmmz6BrggxomoSlnsRFb5dM,1174
|
|
50
50
|
sycommon/tools/timing.py,sha256=OiiE7P07lRoMzX9kzb8sZU9cDb0zNnqIlY5pWqHcnkY,2064
|
|
51
|
-
sycommon_python_lib-0.1.
|
|
52
|
-
sycommon_python_lib-0.1.
|
|
53
|
-
sycommon_python_lib-0.1.
|
|
54
|
-
sycommon_python_lib-0.1.
|
|
55
|
-
sycommon_python_lib-0.1.
|
|
51
|
+
sycommon_python_lib-0.1.27.dist-info/METADATA,sha256=tgr4tP4xxA0OPHY7cRQzcRjMSHLN3bDlKYq_dCuoLRY,7038
|
|
52
|
+
sycommon_python_lib-0.1.27.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
53
|
+
sycommon_python_lib-0.1.27.dist-info/entry_points.txt,sha256=q_h2nbvhhmdnsOUZEIwpuoDjaNfBF9XqppDEmQn9d_A,46
|
|
54
|
+
sycommon_python_lib-0.1.27.dist-info/top_level.txt,sha256=98CJ-cyM2WIKxLz-Pf0AitWLhJyrfXvyY8slwjTXNuc,17
|
|
55
|
+
sycommon_python_lib-0.1.27.dist-info/RECORD,,
|
|
File without changes
|
{sycommon_python_lib-0.1.26.dist-info → sycommon_python_lib-0.1.27.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|