From 1be8fb3aed3f8a55c0dcb6d021685cbb2c79e6ec Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期三, 20 三月 2024 18:47:54 +0800
Subject: [PATCH] 接口调整

---
 log_module/async_log_util.py |   35 +++++++++--------------------------
 1 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/log_module/async_log_util.py b/log_module/async_log_util.py
index f54d5b2..811765e 100644
--- a/log_module/async_log_util.py
+++ b/log_module/async_log_util.py
@@ -39,7 +39,7 @@
                 cmd = val[2]
                 method = getattr(val[0], cmd)
                 d = list(val[3])
-                d[0] = f"[{tool.to_time_str(int(time_s))}.{str(time_s).split('.')[1][:3]}] " + d[0]
+                d[0] = f"[{tool.to_time_str(int(time_s))}.{str(time_s).split('.')[1][:6]}] " + d[0]
                 d = tuple(d)
                 method(*d)
             except:
@@ -48,55 +48,38 @@
 
 l2_data_log = AsyncLogManager()
 
-
 huaxin_l2_log = AsyncLogManager()
 
-
-log_queue = queue.Queue()
-
-
-def __add_log(logger, method, *args):
-    log_queue.put_nowait((logger, time.time(), method, args))
+__common_log = AsyncLogManager()
 
 
 def debug(logger, *args):
-    __add_log(logger, "debug", *args)
+    __common_log.debug(logger, *args)
 
 
 def info(logger, *args):
-    __add_log(logger, "info", *args)
+    __common_log.info(logger, *args)
 
 
 def warning(logger, *args):
-    __add_log(logger, "warning", *args)
+    __common_log.warning(logger, *args)
 
 
 def error(logger, *args):
-    __add_log(logger, "error", *args)
+    __common_log.error(logger, *args)
 
 
 def exception(logger, *args):
-    __add_log(logger, "exception", *args)
+    __common_log.exception(logger, *args)
 
 
 # 杩愯鍚屾鏃ュ織
 def run_sync():
     logger_system.info(f"async_log 绾跨▼ID:{tool.get_thread_id()}")
-    while True:
-        try:
-            val = log_queue.get()
-            time_s = val[1]
-            cmd = val[2]
-            method = getattr(val[0], cmd)
-            d = list(val[3])
-            d[0] = f"[{tool.to_time_str(int(time_s))}.{str(time_s).split('.')[1][:3]}] " + d[0]
-            d = tuple(d)
-            method(*d)
-        except:
-            pass
+    __common_log.run_sync()
 
 
 if __name__ == "__main__":
     # info(logger_debug, "*-{}", "test")
-    info(logger_debug, "123123")
+    info(logger_debug, "002375")
     run_sync()

--
Gitblit v1.8.0