sanic/sanic/log.py

64 lines
1.6 KiB
Python
Raw Normal View History

2016-10-15 20:59:00 +01:00
import logging
2017-09-13 18:35:34 +01:00
import sys
2016-10-15 20:59:00 +01:00
2017-09-11 07:19:09 +01:00
LOGGING_CONFIG_DEFAULTS = dict(
2017-09-13 15:40:42 +01:00
version=1,
disable_existing_loggers=False,
2017-09-11 07:19:09 +01:00
2017-09-13 15:40:42 +01:00
loggers={
"root": {
"level": "INFO",
"handlers": ["console"]
2017-09-11 07:19:09 +01:00
},
2017-09-13 15:40:42 +01:00
"sanic.error": {
"level": "INFO",
"handlers": ["error_console"],
"propagate": True,
"qualname": "sanic.error"
2017-09-11 07:19:09 +01:00
},
2017-09-13 15:40:42 +01:00
"sanic.access": {
"level": "INFO",
"handlers": ["access_console"],
"propagate": True,
"qualname": "sanic.access"
2017-09-11 07:19:09 +01:00
}
2017-09-13 15:40:42 +01:00
},
handlers={
"console": {
"class": "logging.StreamHandler",
"formatter": "generic",
2017-09-13 18:35:34 +01:00
"stream": sys.stdout
2017-09-13 15:40:42 +01:00
},
"error_console": {
"class": "logging.StreamHandler",
"formatter": "generic",
2017-09-13 18:35:34 +01:00
"stream": sys.stderr
2017-09-13 15:40:42 +01:00
},
"access_console": {
"class": "logging.StreamHandler",
"formatter": "access",
2017-09-13 18:35:34 +01:00
"stream": sys.stdout
2017-09-13 15:40:42 +01:00
},
},
formatters={
"generic": {
"format": "%(asctime)s [%(process)d] [%(levelname)s] %(message)s",
"datefmt": "[%Y-%m-%d %H:%M:%S %z]",
"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"
},
}
2017-09-11 07:19:09 +01:00
)
2017-09-12 06:12:49 +01:00
logger = logging.getLogger('root')
2017-09-11 07:19:09 +01:00
error_logger = logging.getLogger('sanic.error')
access_logger = logging.getLogger('sanic.access')