Jelajahi Sumber

诊断日志接口添加日志

tanghongbin 4 tahun lalu
induk
melakukan
dd2e23dc2a
2 mengubah file dengan 11 tambahan dan 0 penghapusan
  1. 1 0
      Controller/AppLogController.py
  2. 10 0
      Service/ModelService.py

+ 1 - 0
Controller/AppLogController.py

@@ -71,6 +71,7 @@ class AppLogView(View):
         if uid is None or average_delay is None or status is None or filename is None:
             return response.json(444)
         else:
+            ModelService.app_log_log(userID, uid)
             now_time = int(time.time())
             data = {
                 'uid': uid,

+ 10 - 0
Service/ModelService.py

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