Przeglądaj źródła

注释异步推送方式,正式配置日志增加time目录

locky 1 rok temu
rodzic
commit
e803f2892e

+ 14 - 1
AnsjerPush/cn_config/cn_formal_settings.py

@@ -171,7 +171,6 @@ LOGGING = {
     'disable_existing_loggers': True,
     'formatters': {
         'error_format': {
-            # 'format': '{"asctime":"%(asctime)s","thread":"%(threadName)s:%(thread)d","errorline":"%(lineno)d","errorlevel":"%(levelname)s","errorcontent":"%(message)s"}'
             'format': '%(asctime)s %(threadName)s %(thread)d %(lineno)d %(levelname)s %(message)s'
         },
         'standard': {
@@ -208,6 +207,15 @@ LOGGING = {
             'formatter': 'standard',
             'encoding': 'utf-8',
         },
+        'time': {
+            'level': 'INFO',
+            'class': 'logging.handlers.TimedRotatingFileHandler',
+            'filename': BASE_DIR + '/static/log/time/info.log',
+            'backupCount': 30,
+            'when': 'D',
+            'formatter': 'standard',
+            'encoding': 'utf-8',
+        },
     },
     'loggers': {
         'django': {
@@ -221,6 +229,11 @@ LOGGING = {
             'handlers': ['info'],
             'level': 'INFO',
             'propagate': False
+        },
+        'time': {
+            'handlers': ['time'],
+            'level': 'INFO',
+            'propagate': False
         }
     }
 }

+ 14 - 0
AnsjerPush/eur_config/eur_formal_settings.py

@@ -202,6 +202,15 @@ LOGGING = {
             'formatter': 'standard',
             'encoding': 'utf-8',
         },
+        'time': {
+            'level': 'INFO',
+            'class': 'logging.handlers.TimedRotatingFileHandler',
+            'filename': BASE_DIR + '/static/log/time/info.log',
+            'backupCount': 30,
+            'when': 'D',
+            'formatter': 'standard',
+            'encoding': 'utf-8',
+        },
     },
     'loggers': {
         'django': {
@@ -215,6 +224,11 @@ LOGGING = {
             'handlers': ['info'],
             'level': 'INFO',
             'propagate': False
+        },
+        'time': {
+            'handlers': ['time'],
+            'level': 'INFO',
+            'propagate': False
         }
     }
 }

+ 14 - 0
AnsjerPush/us_config/formal_settings.py

@@ -209,6 +209,15 @@ LOGGING = {
             'formatter': 'standard',
             'encoding': 'utf-8',
         },
+        'time': {
+            'level': 'INFO',
+            'class': 'logging.handlers.TimedRotatingFileHandler',
+            'filename': BASE_DIR + '/static/log/time/info.log',
+            'backupCount': 30,
+            'when': 'D',
+            'formatter': 'standard',
+            'encoding': 'utf-8',
+        },
     },
     'loggers': {
         'django': {
@@ -222,6 +231,11 @@ LOGGING = {
             'handlers': ['info'],
             'level': 'INFO',
             'propagate': False
+        },
+        'time': {
+            'handlers': ['time'],
+            'level': 'INFO',
+            'propagate': False
         }
     }
 }

+ 14 - 5
Controller/DetectControllerV2.py

@@ -125,12 +125,21 @@ class NotificationV2View(View):
                       'dealings_type': dealings_type, 'detection': detection,
                       'app_push_config': uid_set_push_list[0]['uid_set__msg_notify']}
 
+            # 推送消息,生成推送数据列表
+            result = DevicePushService.save_msg_push(uid_set_push_list, **params)
+            # 保存推送数据
+            DevicePushService.save_sys_msg(
+                is_sys_msg,
+                result['local_date_time'],
+                result['sys_msg_list'],
+                result['new_device_info_list'])
+
             # 异步推送消息和保存数据
-            push_thread = threading.Thread(
-                target=push_and_save_data,
-                args=(uid_set_push_list, is_sys_msg),
-                kwargs=params)
-            push_thread.start()
+            # push_thread = threading.Thread(
+            #     target=push_and_save_data,
+            #     args=(uid_set_push_list, is_sys_msg),
+            #     kwargs=params)
+            # push_thread.start()
 
             params['aws_s3_client'] = aws_s3_client
             params['uid_set_push_list'] = uid_set_push_list