yf_yzl 2 лет назад
Родитель
Сommit
150c9ccda5
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      smartfarming/views/upload_apk.py

+ 5 - 2
smartfarming/views/upload_apk.py

@@ -4,7 +4,7 @@ from rest_framework.response import Response
 from rest_framework.parsers import FileUploadParser
 from kedong.settings import MEDIA_ROOT
 import time
-import uuid
+import logging
 from datetime import datetime
 from django.conf import settings
 from smartfarming.models.agriculture import APKLogs
@@ -13,6 +13,8 @@ from smartfarming.serializers.apk_serializers import APKLogsSerializers
 
 config = settings.CONFIG
 
+logger = logging.getLogger("myapp")
+
 class NewUploadAPIView(APIView):
     # 上传apk文件
     def post(self, request):
@@ -43,6 +45,7 @@ class NewUploadAPIView(APIView):
             url = f'{proxy_front}/{file_name}'
             return Response({"url": url, "old_url": download_url, "code": 0, "msg": "success"})
         except Exception as e:
+            logger.error(e)
             return Response({"code": 2, "msg": "APK保存失败,请检查或重试"})
 
 
@@ -62,7 +65,7 @@ class APKUploadView(APIView):
             app.save()
             return Response({"code": 0, "msg": "success"})
         except Exception as e:
-            print(e)
+            logger.error(e)
             return Response({"code": 1, "msg": "保存失败"})