Improve auth server logging

This commit is contained in:
Tanner Collin 2020-11-23 07:27:21 +00:00
parent e6d230a04e
commit 5c4e0943d0

View File

@ -1,22 +1,60 @@
import logging import logging
import logging.config import logging.config
logging.config.dictConfig({ class IgnorePing(logging.Filter):
def filter(self, record):
return 'GET /ping' not in record.getMessage()
LOG_DICT = {
'version': 1, 'version': 1,
'formatters': {'default': { 'formatters': {
'format': '[%(asctime)s] [%(process)d] [%(levelname)7s] %(message)s', 'default': {
}}, 'format': '[%(asctime)s] [%(process)d] [%(levelname)7s] %(message)s',
'handlers': {'wsgi': { },
'class': 'logging.StreamHandler', },
'stream': 'ext://flask.logging.wsgi_errors_stream', 'filters': {
'formatter': 'default' 'ignore_ping': {
}}, '()': 'log.IgnorePing',
},
},
'handlers': {
'wsgi': {
'class': 'logging.StreamHandler',
'filters': ['ignore_ping'],
'stream': 'ext://flask.logging.wsgi_errors_stream',
'formatter': 'default'
},
'console': {
'level': 'DEBUG',
'filters': ['ignore_ping'],
'class': 'logging.StreamHandler',
'formatter': 'default'
},
'null': {
'level': 'DEBUG',
'filters': ['ignore_ping'],
'class': 'logging.NullHandler',
'formatter': 'default'
},
},
'loggers': {
'gunicorn': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
},
'root': { 'root': {
'level': 'INFO', 'level': 'INFO',
'handlers': ['wsgi'] 'handlers': ['wsgi']
} }
}) }
logging.config.dictConfig(LOG_DICT)
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
logger.info('Logging enabled.') logger.info('Logging enabled.')
from logging_tree import printout
printout()