Browse Source

设备新版上传添加日志

guanhailong 2 năm trước cách đây
mục cha
commit
3895446f12
1 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 5 1
      AdminController/VersionManagementController.py

+ 5 - 1
AdminController/VersionManagementController.py

@@ -3,6 +3,7 @@
 import os
 import hashlib
 import time
+import logging
 
 import boto3
 import botocore
@@ -104,6 +105,7 @@ class VersionManagement(View):
             return response.json(500, repr(e))
 
     def upLoadFile(self, request, request_dict, response):
+        LOGGER = logging.getLogger('info')
         file = request.FILES.get('file', None)
         mci = request_dict.get('mci', '')
         lang = request_dict.get('lang', '')
@@ -165,9 +167,11 @@ class VersionManagement(View):
             with open(full_name, 'wb+') as write_file:
                 for chunk in file.chunks():
                     write_file.write(chunk)
+            LOGGER.info('上传{}成功'.format(file_name))
             return response.json(0)
         except Exception as e:
-            print(e)
+            LOGGER.info("错误行数:{errLine}".format(errLine=e.__traceback__.tb_lineno))
+            LOGGER.info('上传异常{}'.format(e))
             return response.json(500, repr(e))
 
     def editVersionInformation(self, request_dict, response):