Browse Source

优化打印、修改日志保留按天保留

zhangdongming 2 năm trước cách đây
mục cha
commit
6318b57d53

+ 3 - 3
AnsjerPush/cn_config/cn_formal_settings.py

@@ -193,10 +193,10 @@ LOGGING = {
         },
         'info': {
             'level': 'INFO',
-            'class': 'logging.handlers.RotatingFileHandler',
+            'class': 'logging.handlers.TimedRotatingFileHandler',
             'filename': BASE_DIR + '/static/log/info/info.log',
-            'backupCount': 10,
-            'maxBytes': 1024 * 1024 * 1024,  # 1G
+            'backupCount': 7,
+            'when': 'D',
             'formatter': 'standard',
             'encoding': 'utf-8',
         },

+ 0 - 4
Controller/DetectController.py

@@ -36,7 +36,6 @@ class NotificationView(View):
         @param request_dict:is_st 文件类型(0:无,1:图片,2:视频)
         """
         logger = logging.getLogger('info')
-        logger.info("旧移动侦测接口参数:{}".format(request_dict))
         uidToken = request_dict.get('uidToken', None)
         etk = request_dict.get('etk', None)
         channel = request_dict.get('channel', '1')
@@ -111,8 +110,6 @@ class NotificationView(View):
                         detect_interval = 60 if detect_interval < 60 else detect_interval
                     redisObj.set_data(key=dkey, val=1, expire=detect_interval - 5)
                     redisObj.set_data(key=pkey, val=1, expire=60)
-            logger.info(
-                'APP消息推送V1接口,是否进行APP推送:{},1为不推送,间隔:{}'.format(detect_med_type, detect_interval))
             # 旧模式并且没有pkey,重新创建一个
             if not detect_group and not have_pkey:
                 redisObj.set_data(key=pkey, val=1, expire=60)
@@ -143,7 +140,6 @@ class NotificationView(View):
                     # 根据日期获得星期几
                     week = LocalDateTimeUtil.date_to_week(result['local_date_time'])
                     EquipmentInfoService.equipment_info_bulk_create(week, result['new_device_info_list'])
-                    logger.info('----《旧接口》设备信息分表批量保存end')
             if is_st == '0' or is_st == '2':
                 print("is_st=0or2")
                 for up in uid_push_list:

+ 0 - 5
Object/utils/LocalDateTimeUtil.py

@@ -64,15 +64,10 @@ def date_to_week(str_date):
     @param str_date 日期 例:2022-03-03
     @return: int 1-7
     """
-    logger = logging.getLogger('info')
     if str_date:
-        logger.info('-----进入日期转星期-----')
         dt = pendulum.parse(str_date).day_of_week
         dt = 7 if dt == 0 else dt
-        logger.info('---根据pendulum模块解析后=星期{}'.format(dt))
         return dt
     return datetime.datetime.now().weekday() + 1
 
 
-if __name__ == "__main__":
-    print('')

+ 0 - 5
Service/DevicePushService.py

@@ -140,11 +140,8 @@ class DevicePushService:
                 kwag_args['token_val'] = token_val
                 kwag_args['msg_title'] = msg_title
                 kwag_args['msg_text'] = msg_text
-                LOGGING.info('推送要的数据: {}'.format(kwag_args))
                 local_date_time = CommonService.get_now_time_str(n_time=params['n_time'], tz=tz, lang='cn')
-                LOGGING.info('<<<<<根据时区计算后日期={},时区={}'.format(local_date_time, tz))
                 local_date_time = local_date_time[0:10]
-                LOGGING.info('<<<<<切片后的日期={}'.format(local_date_time))
                 # 以下是存库
                 userID_id = up["userID_id"]
                 if userID_id not in userID_ids:
@@ -159,7 +156,6 @@ class DevicePushService:
                                                         updTime=now_time, uid=params['uid'],
                                                         eventType=params['event_type']))
                     else:
-                        LOGGING.info('分表存数据start------')
                         params['userID_id'] = userID_id
                         # push_permission = DevicePushService.check_share_permission(userID_id,
                         # params['channel'],params['uid'])
@@ -297,7 +293,6 @@ class DevicePushService:
                 # 根据日期获得星期几
                 week = LocalDateTimeUtil.date_to_week(local_date_time)
                 EquipmentInfoService.equipment_info_bulk_create(week, new_device_info_list)
-                LOGGING.info('设备信息分表批量保存end------')
         return True
 
     @classmethod

+ 0 - 1
Service/EquipmentInfoService.py

@@ -27,7 +27,6 @@ class EquipmentInfoService:
         """
         logger = logging.getLogger('info')
         week = LocalDateTimeUtil.date_to_week(dt)
-        logger.info('本周{}'.format(str(week)))
         equipment_info = None
         if week == 1:
             equipment_info = EquipmentInfoMonday(**kwargs)