|
@@ -11,81 +11,134 @@ LOGGING_CONFIG = dict(
|
|
version=1,
|
|
version=1,
|
|
disable_existing_loggers=False,
|
|
disable_existing_loggers=False,
|
|
loggers={
|
|
loggers={
|
|
- "sanic.root": {
|
|
|
|
- "level": "INFO", # 默认DEBUG
|
|
|
|
- "handlers": ["console"]
|
|
|
|
|
|
+ # 新曾自定义日志,用于数据采集程序
|
|
|
|
+ "console": {
|
|
|
|
+ "level": "DEBUG",
|
|
|
|
+ "handlers": ["console", "connector_file"],
|
|
|
|
+ "propagate": True,
|
|
|
|
+ "qualname": "console.debug",
|
|
},
|
|
},
|
|
- "sanic.error": {
|
|
|
|
- "level": "INFO",
|
|
|
|
- "handlers": ["error_console"],
|
|
|
|
|
|
+ "sm140_file": {
|
|
|
|
+ "level": "DEBUG",
|
|
|
|
+ "handlers": ["console", "sm140_file"],
|
|
"propagate": True,
|
|
"propagate": True,
|
|
- "qualname": "sanic.error",
|
|
|
|
|
|
+ "qualname": "sm140.debug",
|
|
},
|
|
},
|
|
- "sanic.access": {
|
|
|
|
- "level": "INFO", # 默认DEBUG
|
|
|
|
- "handlers": ["access_console"],
|
|
|
|
|
|
+ "wxt536_file": {
|
|
|
|
+ "level": "DEBUG",
|
|
|
|
+ "handlers": ["console", "wxt536_file"],
|
|
"propagate": True,
|
|
"propagate": True,
|
|
- "qualname": "sanic.access",
|
|
|
|
|
|
+ "qualname": "wxt536.debug",
|
|
},
|
|
},
|
|
- # 新曾自定义日志,用于数据采集程序
|
|
|
|
- "sanic.my": {
|
|
|
|
- "level": "INFO",
|
|
|
|
- "handlers": ["my_console", "file_console"],
|
|
|
|
|
|
+ "adcp_file": {
|
|
|
|
+ "level": "DEBUG",
|
|
|
|
+ "handlers": ["console", "adcp_file"],
|
|
"propagate": True,
|
|
"propagate": True,
|
|
- "qualname": "my.debug",
|
|
|
|
|
|
+ "qualname": "adcp.debug",
|
|
|
|
+ },
|
|
|
|
+ "dandian_file": {
|
|
|
|
+ "level": "DEBUG",
|
|
|
|
+ "handlers": ["console", "dandian_file"],
|
|
|
|
+ "propagate": True,
|
|
|
|
+ "qualname": "dandian.debug",
|
|
|
|
+ },
|
|
|
|
+ "td266_file": {
|
|
|
|
+ "level": "DEBUG",
|
|
|
|
+ "handlers": ["console", "td266_file"],
|
|
|
|
+ "propagate": True,
|
|
|
|
+ "qualname": "td266.debug",
|
|
|
|
+ },
|
|
|
|
+ "shuizhi_file": {
|
|
|
|
+ "level": "DEBUG",
|
|
|
|
+ "handlers": ["console", "shuizhi_file"],
|
|
|
|
+ "propagate": True,
|
|
|
|
+ "qualname": "shuizhi.debug",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
handlers={
|
|
handlers={
|
|
|
|
+ # 数据采集程序控制台输出handler
|
|
"console": {
|
|
"console": {
|
|
"class": "logging.StreamHandler",
|
|
"class": "logging.StreamHandler",
|
|
"formatter": "generic",
|
|
"formatter": "generic",
|
|
"stream": sys.stdout,
|
|
"stream": sys.stdout,
|
|
},
|
|
},
|
|
- "error_console": {
|
|
|
|
- "class": "logging.StreamHandler",
|
|
|
|
|
|
+ "connector_file": {
|
|
|
|
+ 'class': 'logging.handlers.RotatingFileHandler',
|
|
|
|
+ 'filename': 'log/connector_log/connector_file.log',
|
|
|
|
+ 'maxBytes': 10 * 1024 * 1024,
|
|
|
|
+ 'delay': True,
|
|
"formatter": "generic",
|
|
"formatter": "generic",
|
|
- "stream": sys.stderr,
|
|
|
|
|
|
+ "backupCount": 20,
|
|
|
|
+ "encoding": "utf-8"
|
|
},
|
|
},
|
|
- "access_console": {
|
|
|
|
- "class": "logging.StreamHandler",
|
|
|
|
- "formatter": "access",
|
|
|
|
- "stream": sys.stdout,
|
|
|
|
|
|
+ "sm140_file": {
|
|
|
|
+ 'class': 'logging.handlers.RotatingFileHandler',
|
|
|
|
+ 'filename': 'log/sm140_log/sm140_file.log',
|
|
|
|
+ 'maxBytes': 10 * 1024 * 1024,
|
|
|
|
+ 'delay': True,
|
|
|
|
+ "formatter": "generic",
|
|
|
|
+ "backupCount": 20,
|
|
|
|
+ "encoding": "utf-8"
|
|
},
|
|
},
|
|
- # 数据采集程序控制台输出handler
|
|
|
|
- "my_console": {
|
|
|
|
- "class": "logging.StreamHandler",
|
|
|
|
- "formatter": "my",
|
|
|
|
- "stream": sys.stdout,
|
|
|
|
|
|
+ "wxt536_file": {
|
|
|
|
+ 'class': 'logging.handlers.RotatingFileHandler',
|
|
|
|
+ 'filename': 'log/wxt536_log/wxt536_log.log',
|
|
|
|
+ 'maxBytes': 10 * 1024 * 1024,
|
|
|
|
+ 'delay': True,
|
|
|
|
+ "formatter": "generic",
|
|
|
|
+ "backupCount": 20,
|
|
|
|
+ "encoding": "utf-8"
|
|
},
|
|
},
|
|
- # 数据采集程序文件输出handler
|
|
|
|
- "file_console": {
|
|
|
|
|
|
+ "adcp_file": {
|
|
'class': 'logging.handlers.RotatingFileHandler',
|
|
'class': 'logging.handlers.RotatingFileHandler',
|
|
- 'filename': 'app.log',
|
|
|
|
- 'maxBytes': 200 * 1024,
|
|
|
|
|
|
+ 'filename': 'log/adcp_log/adcp_log.log',
|
|
|
|
+ 'maxBytes': 10 * 1024 * 1024,
|
|
'delay': True,
|
|
'delay': True,
|
|
- "formatter": "my",
|
|
|
|
- "backupCount": 10,
|
|
|
|
|
|
+ "formatter": "generic",
|
|
|
|
+ "backupCount": 20,
|
|
|
|
+ "encoding": "utf-8"
|
|
|
|
+ },
|
|
|
|
+ "dandian_file": {
|
|
|
|
+ 'class': 'logging.handlers.RotatingFileHandler',
|
|
|
|
+ 'filename': 'log/dandian_log/dandian_log.log',
|
|
|
|
+ 'maxBytes': 10 * 1024 * 1024,
|
|
|
|
+ 'delay': True,
|
|
|
|
+ "formatter": "generic",
|
|
|
|
+ "backupCount": 20,
|
|
|
|
+ "encoding": "utf-8"
|
|
|
|
+ },
|
|
|
|
+ "td266_file": {
|
|
|
|
+ 'class': 'logging.handlers.RotatingFileHandler',
|
|
|
|
+ 'filename': 'log/td266_log/td266_log.log',
|
|
|
|
+ 'maxBytes': 10 * 1024 * 1024,
|
|
|
|
+ 'delay': True,
|
|
|
|
+ "formatter": "generic",
|
|
|
|
+ "backupCount": 20,
|
|
|
|
+ "encoding": "utf-8"
|
|
|
|
+ },
|
|
|
|
+ "shuizhi_file": {
|
|
|
|
+ 'class': 'logging.handlers.RotatingFileHandler',
|
|
|
|
+ 'filename': 'log/shuizhi_log/shuizhi_log.log',
|
|
|
|
+ 'maxBytes': 10 * 1024 * 1024,
|
|
|
|
+ 'delay': True,
|
|
|
|
+ "formatter": "generic",
|
|
|
|
+ "backupCount": 20,
|
|
"encoding": "utf-8"
|
|
"encoding": "utf-8"
|
|
},
|
|
},
|
|
},
|
|
},
|
|
formatters={
|
|
formatters={
|
|
- "generic": {
|
|
|
|
- "format": "%(asctime)s [%(process)d] [%(levelname)s] %(message)s",
|
|
|
|
- "datefmt": "[%Y-%m-%d %H:%M:%S %z]",
|
|
|
|
- "class": "logging.Formatter",
|
|
|
|
- },
|
|
|
|
# 自定义文件格式化器
|
|
# 自定义文件格式化器
|
|
- "my": {
|
|
|
|
|
|
+ "generic": {
|
|
"format": "%(asctime)s [%(filename)s:%(lineno)d] [%(levelname)s] %(message)s",
|
|
"format": "%(asctime)s [%(filename)s:%(lineno)d] [%(levelname)s] %(message)s",
|
|
"datefmt": "[%Y-%m-%d %H:%M:%S]",
|
|
"datefmt": "[%Y-%m-%d %H:%M:%S]",
|
|
"class": "logging.Formatter",
|
|
"class": "logging.Formatter",
|
|
},
|
|
},
|
|
- "access": {
|
|
|
|
- "format": "%(asctime)s - (%(name)s) [%(levelname)s][%(host)s]: "
|
|
|
|
- + "%(request)s %(message)s %(status)d %(byte)d",
|
|
|
|
- "datefmt": "[%Y-%m-%d %H:%M:%S %z]",
|
|
|
|
- "class": "logging.Formatter",
|
|
|
|
- },
|
|
|
|
},
|
|
},
|
|
)
|
|
)
|
|
-logger = logging.getLogger("sanic.my")
|
|
|
|
|
|
+logger = logging.getLogger("console")
|
|
|
|
+sm140_file_logger = logging.getLogger("sm140_file")
|
|
|
|
+wxt536_file_logger = logging.getLogger("wxt536_file")
|
|
|
|
+adcp_file_logger = logging.getLogger("adcp_file")
|
|
|
|
+dandian_file_logger = logging.getLogger("dandian_file")
|
|
|
|
+td266_file_logger = logging.getLogger("td266_file")
|
|
|
|
+shuizhi_file_logger = logging.getLogger("shuizhi_file")
|