From 89a673df861e4a6cf0f8507b96018dbaced0086d Mon Sep 17 00:00:00 2001
From: shidong <shidong@jhsoft.cc>
Date: 星期五, 11 七月 2025 14:08:45 +0800
Subject: [PATCH] #2025/7/11 #qwen_detect.py和qwen_thread.py优化了日志输出,采用一个日志,方便后期排查问题 #conf.txt从服务器获取的最新配置文件,备份 #批量处理的效果太差,比单张慢两倍,留存qwen_detect_batch.py和qwen_thread_batch.py

---
 qwen_detect.py |   44 +++++++++++++++++++++++---------------------
 1 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/qwen_detect.py b/qwen_detect.py
index 75249d0..b27a87b 100644
--- a/qwen_detect.py
+++ b/qwen_detect.py
@@ -29,26 +29,8 @@
                     value = value.strip()
                     # 灏嗛敭鍊煎娣诲姞鍒板瓧鍏镐腑
                     self.config[key] = value
-        # 閰嶇疆鏃ュ織
-        # 纭繚鏃ュ織鐩綍瀛樺湪
-        log_dir = "logs"
-        os.makedirs(log_dir, exist_ok=True)
-        self.threads: Dict[str, threading.Thread] = {}
-        self.lock = threading.Lock()
-
-        # 鍒濆鍖朚ilvus闆嗗悎
-        connections.connect("default", host=self.config.get("milvusurl"), port=self.config.get("milvusport"))
-        # 鍔犺浇闆嗗悎
-        self.collection = Collection(name="smartobject")
-        self.collection.load()
-        self.pool = qwen_thread(self.config)
-        #鏄惁鏇存柊
-        self._isupdate = False
-
-        # 鍒濆鍖栧叡浜唴瀛�
-        get_mem.smem_init()
-
-        # 閰嶇疆鏃ュ織
+        # 鍒涘缓瀹炰緥涓撳睘logger
+        os.makedirs("logs", exist_ok=True)
         logging.basicConfig(
             level=logging.INFO,
             format='%(asctime)s - %(filename)s:%(lineno)d - %(funcName)s() - %(levelname)s: %(message)s',
@@ -56,7 +38,7 @@
             handlers=[
                 # 鎸夊ぇ灏忚疆杞殑鏃ュ織鏂囦欢锛堟渶澶�10MB锛屼繚鐣�3涓浠斤級
                 RotatingFileHandler(
-                    filename=os.path.join(log_dir, 'start_log.log'),
+                    filename=os.path.join("logs", 'qwen_log.log'),
                     maxBytes=10 * 1024 * 1024,  # 10MB
                     backupCount=3,
                     encoding='utf-8'
@@ -65,6 +47,26 @@
                 logging.StreamHandler()
             ]
         )
+        self.logger = logging.getLogger(f"{self.__class__}_{id(self)}")
+        self.logger.setLevel(logging.INFO)
+
+
+        self.threads: Dict[str, threading.Thread] = {}
+        self.lock = threading.Lock()
+
+        # 鍒濆鍖朚ilvus闆嗗悎
+        connections.connect("default", host=self.config.get("milvusurl"), port=self.config.get("milvusport"))
+        # 鍔犺浇闆嗗悎
+        self.collection = Collection(name="smartobject")
+        self.collection.load()
+        #鍒涘缓qwen绾跨▼姹�
+        self.pool = qwen_thread(self.config,self.logger)
+        #鏄惁鏇存柊
+        self._isupdate = False
+
+        # 鍒濆鍖栧叡浜唴瀛�
+        get_mem.smem_init()
+
 
     #鍚姩绾跨▼
     def safe_start(self, target_func, camera_id):

--
Gitblit v1.8.0