DavidLiu hai 3 meses
pai
achega
a19d9a0408
Modificáronse 2 ficheiros con 10 adicións e 7 borrados
  1. 3 1
      src/core/callcenter/cache.py
  2. 7 6
      src/core/callcenter/config.py

+ 3 - 1
src/core/callcenter/cache.py

@@ -6,13 +6,15 @@ import sys
 import time
 import uuid
 from datetime import datetime
+
+from src.core import singleton_keys
 from src.core.callcenter.constant import *
 from src.core.callcenter.api import AgentInfo, CallInfo, RouteGateway
 from src.core.callcenter.dao import Agent, Phone
 from src.core.callcenter.data_handler import DataHandleServer
 from src.core.datasource import RedisHandler
 
-
+@singleton_keys
 class Cache:
     def __init__(self, app):
         self.cacheDay = 7

+ 7 - 6
src/core/callcenter/config.py

@@ -23,7 +23,7 @@ class BaseConfig(object):
 
 dictConfig({
         "version": 1,
-        "disable_existing_loggers": False,  # 不覆盖默认配置
+        "disable_existing_loggers": True,  # 不覆盖默认配置
         "formatters": {  # 日志输出样式
             "default": {
                 "format": "%(asctime)s - %(module)s.%(lineno)d - %(levelname)s - %(threadName)s: %(message)s"
@@ -36,13 +36,14 @@ dictConfig({
                 "formatter": "default",
             },
             "log_file": {
-                "class": "logging.handlers.RotatingFileHandler",
-                "level": "INFO",
+                "class": "logging.handlers.TimedRotatingFileHandler",  # 按时间切分日志
+                "level": "DEBUG",
                 "formatter": "default",   # 日志输出样式对应formatters
                 "filename": "./logs/flask.log",  # 指定log文件目录
-                "maxBytes": 20*1024*1024,   # 文件最大20M
-                "backupCount": 10,          # 最多10个文件
-                "encoding": "utf8",         # 文件编码
+                "when": "midnight",        # 按天切分,午夜时分创建新文件
+                "interval": 1,             # 间隔1天
+                "backupCount": 10,         # 保留10天的日志文件
+                "encoding": "utf8",        # 文件编码
             },
 
         },