Browse Source

master添加异常日志5

tanghongbin 4 years ago
parent
commit
fc4e91e6a6
2 changed files with 14 additions and 4 deletions
  1. 3 3
      Controller/EquipmentManager.py
  2. 11 1
      Service/ModelService.py

+ 3 - 3
Controller/EquipmentManager.py

@@ -164,7 +164,7 @@ def delUserEquipmentInterface(request):
         # redisObj.del_data(key='uid_qs_' + userID)
         if dv_qs.exists():
             uid = dv_qs[0].UID
-            asy = threading.Thread(target=ModelService.add_log, args=(CommonService.get_ip_address(request), userID, 'deleteV0'))
+            asy = threading.Thread(target=ModelService.delete_log, args=(CommonService.get_ip_address(request), userID, 'deleteV0', uid))
             asy.start()
 
             print('删除')
@@ -680,8 +680,8 @@ def deleteInterface(request):
         dv_qs = Device_Info.objects.filter(userID_id=userID, id=id)
         if dv_qs.exists():
             uid = dv_qs[0].UID
-            asy = threading.Thread(target=ModelService.add_log,
-                                   args=(CommonService.get_ip_address(request), userID, 'deleteV1'))
+            asy = threading.Thread(target=ModelService.delete_log,
+                                   args=(CommonService.get_ip_address(request), userID, 'deleteV1', uid))
             asy.start()
 
             if dv_qs[0].isShare:

+ 11 - 1
Service/ModelService.py

@@ -174,7 +174,7 @@ class ModelService:
 
     @staticmethod
     def add_log(ip, userID, operation):
-        file_path = '/'.join((BASE_DIR, 'static/delete_device.log'))
+        file_path = '/'.join((BASE_DIR, 'static/add_device.log'))
         file = open(file_path, 'a+')
         file.write(ip + "; username:" + userID + "; time:" + time.strftime(
                 "%Y-%m-%d %H:%M:%S", time.localtime()) + "; " + operation)
@@ -182,6 +182,16 @@ class ModelService:
         file.flush()
         file.close()
 
+    @staticmethod
+    def delete_log(ip, userID, operation, UID):
+        file_path = '/'.join((BASE_DIR, 'static/delete_device.log'))
+        file = open(file_path, 'a+')
+        file.write(ip + "; username:" + userID + "; time:" + time.strftime(
+            "%Y-%m-%d %H:%M:%S", time.localtime()) + "; " + operation + "; uid:"+UID)
+        file.write('\n')
+        file.flush()
+        file.close()
+
 
 def notify_alexa_delete(userID, UID):
     url = 'https://www.zositech.xyz/deviceStatus/delete'