فهرست منبع

master添加异常日志9

tanghongbin 4 سال پیش
والد
کامیت
b2708f1ff4
3فایلهای تغییر یافته به همراه15 افزوده شده و 4 حذف شده
  1. 2 2
      Controller/EquipmentManager.py
  2. 2 2
      Controller/EquipmentManagerV3.py
  3. 11 0
      Service/ModelService.py

+ 2 - 2
Controller/EquipmentManager.py

@@ -217,8 +217,8 @@ def modifyUserEquipmentInterface(request):
         if qs.exists():
             uid = qs[0].UID
             if uid == '98UXAA8BRPA35VAL111A':
-                asy = threading.Thread(target=ModelService.add_log,
-                                       args=(CommonService.get_ip_address(request), userID, 'modifyV0'))
+                asy = threading.Thread(target=ModelService.update_log,
+                                       args=(CommonService.get_ip_address(request), userID, 'modifyV0', deviceContent, id))
                 asy.start()
             nickname = qs[0].NickName
             # 增加设备影子信息修改昵称 start

+ 2 - 2
Controller/EquipmentManagerV3.py

@@ -168,8 +168,8 @@ class EquipmentManagerV3(View):
             if qs.exists():
                 uid = qs[0].UID
                 if uid == '98UXAA8BRPA35VAL111A':
-                    asy = threading.Thread(target=ModelService.add_log,
-                                           args=(CommonService.get_ip_address(request), userID, 'modifyV3'))
+                    asy = threading.Thread(target=ModelService.update_log,
+                                           args=(CommonService.get_ip_address(request), userID, 'modifyV3', deviceData, id))
                     asy.start()
                 nickname = qs[0].NickName
                 # 增加设备影子信息修改昵称 start

+ 11 - 0
Service/ModelService.py

@@ -182,6 +182,17 @@ class ModelService:
         file.flush()
         file.close()
 
+    @staticmethod
+    def update_log(ip, userID, operation, content, id):
+        content['xid'] = id
+        file_path = '/'.join((BASE_DIR, 'static/update_device.log'))
+        file = open(file_path, 'a+')
+        file.write(ip + "; username:" + userID + "; time:" + time.strftime(
+            "%Y-%m-%d %H:%M:%S", time.localtime()) + "; content:" + json.dumps(content) + "; " + operation)
+        file.write('\n')
+        file.flush()
+        file.close()
+
     @staticmethod
     def delete_log(ip, userID, operation, UID):
         file_path = '/'.join((BASE_DIR, 'static/delete_device.log'))