Procházet zdrojové kódy

添加日志文件

locky před 4 roky
rodič
revize
8fcc9fbd6d
2 změnil soubory, kde provedl 24 přidání a 2 odebrání
  1. 21 2
      AnsjerUIDManage/settings.py
  2. 3 0
      Controller/AlexaController.py

+ 21 - 2
AnsjerUIDManage/settings.py

@@ -113,10 +113,15 @@ WSGI_APPLICATION = 'AnsjerUIDManage.wsgi.application'
 # HOST = 'localhost'
 
 
+# DATABASES_NAME = 'ansjer_uid'
+# USER_NAME = 'root'
+# USER_PASSWORD = '123456'
+# HOST = 'localhost'
+
 DATABASES_NAME = 'ansjer_uid'
 USER_NAME = 'root'
-USER_PASSWORD = 'ansjer.x.x'
-HOST = 'localhost'
+USER_PASSWORD = '123456'
+HOST = '192.168.136.103'
 
 DATABASES = {
     # 'default': {
@@ -206,6 +211,15 @@ LOGGING = {
             'class': 'logging.StreamHandler',
             'formatter': 'error_format'
         },
+        'info': {
+            'level': 'INFO',
+            'class': 'logging.handlers.TimedRotatingFileHandler',
+            'filename': BASE_DIR + '/static/log/info.log',
+            'maxBytes': 1024 * 1024 * 5,  # 5 MB
+            'backupCount': 5,
+            'formatter': 'standard',
+            'encoding': 'utf-8',
+        },
     },
     'loggers': {
         'django': {
@@ -214,5 +228,10 @@ LOGGING = {
             'level': 'ERROR',
             'propagate': False
         },
+        'info': {
+            'handlers': ['info'],
+            'level': 'INFO',
+            'propagate': False
+        }
     }
 }

+ 3 - 0
Controller/AlexaController.py

@@ -1,3 +1,4 @@
+import logging
 import subprocess
 
 from django.views import View
@@ -27,6 +28,8 @@ class PushCommandView(View):
         try:
             back = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE). \
                                     communicate(timeout=2)
+            djangoLogger = logging.getLogger('django')
+            djangoLogger.info('调用pushtool日志:\n {}'.format(back))
             return HttpResponse(back)
         except Exception as e:
             return HttpResponse(e)