yf_yzl 2 лет назад
Родитель
Сommit
ae07fa6aed
1 измененных файлов с 5 добавлено и 1 удалено
  1. 5 1
      apps/apply_weather.py

+ 5 - 1
apps/apply_weather.py

@@ -1,6 +1,7 @@
 from rest_framework.views import APIView
 from rest_framework.response import Response
 import sqlite3
+import logging
 
 
 province_dict = {
@@ -38,6 +39,9 @@ province_dict = {
 }
 
 
+logging.basicConfig(level=logging.DEBUG, filename='/data/logs/app.log', filemode='w',
+                    format='%(asctime)s - %(levelname)s - %(message)s')
+
 class GetWeather(APIView):
 
     def post(self, request):
@@ -79,7 +83,7 @@ class GetWeather(APIView):
                     result = cursor.fetchone()
             return Response({"content": result})
         except Exception as e:
-            print(e)
+            logging.info(e)
             return Response({"msg": "请联系管理员", "code": "50001"})