From 4bdb9a2c8e0d323352e136624e9558c4d1633aa9 Mon Sep 17 00:00:00 2001 From: Yun Xu Date: Sun, 10 Sep 2017 23:19:09 -0700 Subject: [PATCH] prototype --- sanic/log.py | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/sanic/log.py b/sanic/log.py index a7933c0d..3d254d6c 100644 --- a/sanic/log.py +++ b/sanic/log.py @@ -1,5 +1,56 @@ import logging +LOGGING_CONFIG_DEFAULTS = dict( + version=1, + disable_existing_loggers=False, + + loggers={ + "root": { + "level": "INFO", + "handlers": ["console"]}, + "sanic.error": { + "level": "INFO", + "handlers": ["error_console"], + "propagate": True, + "qualname": "sanic.error" + }, + + "sanic.access": { + "level": "INFO", + "handlers": ["console"], + "propagate": True, + "qualname": "sanic.access" + } + }, + handlers={ + "console": { + "class": "logging.StreamHandler", + "formatter": "generic", + "stream": "sys.stdout" + }, + "error_console": { + "class": "logging.StreamHandler", + "formatter": "generic", + "stream": "sys.stderr" + }, + }, + formatters={ + "generic": { + "format": "%(asctime)s [%(process)d] [%(levelname)s] %(message)s", + "datefmt": "[%Y-%m-%d %H:%M:%S %z]", + "class": "logging.Formatter" + } + } +) + + +class AccessLogger: + + def __init__(self, logger, access_log_format=None): + pass + + log = logging.getLogger('sanic') -netlog = logging.getLogger('network') +error_logger = logging.getLogger('sanic.error') +access_logger = logging.getLogger('sanic.access')