diff --git a/gunicorn-logging-extension/src/gunicorn_logging_extension/__init__.py b/gunicorn-logging-extension/src/gunicorn_logging_extension/__init__.py index ddadcbd..73e764c 100644 --- a/gunicorn-logging-extension/src/gunicorn_logging_extension/__init__.py +++ b/gunicorn-logging-extension/src/gunicorn_logging_extension/__init__.py @@ -10,17 +10,36 @@ from logging.config import dictConfig, fileConfig from gunicorn.glogging import CONFIG_DEFAULTS from gunicorn.glogging import Logger as gLogger -__version__ = "0.0.3" +__version__ = "0.0.5" + + +CONFIG_DEFAULTS = { + "version": 1, + "disable_existing_loggers": False, + "root": {"level": "INFO", "handlers": ["console"]}, + "loggers": {}, + "handlers": { + "console": {"class": "logging.StreamHandler", "formatter": "generic", "stream": "ext://sys.stdout"}, + }, + "formatters": { + "generic": { + "format": "%(asctime)s [%(process)d] [%(levelname)s] %(message)s", + "datefmt": "[%Y-%m-%d %H:%M:%S %z]", + "class": "logging.Formatter", + } + }, +} class Logger(gLogger): + def __init__(self, cfg): - self.error_log = logging.getLogger("gunicorn.error") - self.access_log = logging.getLogger("gunicorn.access") self.logfile = None self.lock = threading.Lock() self.cfg = cfg self.setup(cfg) + self.error_log = logging.getLogger("gunicorn.error") + self.access_log = logging.getLogger("gunicorn.access") def setup(self, cfg): if cfg.logconfig_dict: @@ -60,15 +79,6 @@ class Logger(gLogger): for format details """ - if not ( - self.cfg.accesslog - or self.cfg.logconfig - or self.cfg.logconfig_dict - or self.cfg.logconfig_json - or (self.cfg.syslog and not self.cfg.disable_redirect_access_to_syslog) - ): - return - # wrap atoms: # - make sure atoms will be test case insensitively # - if atom doesn't exist replace it by '-'