spaceport/authserver/log.py

61 lines
1.4 KiB
Python
Raw Normal View History

2020-09-16 21:41:55 +00:00
import logging
import logging.config
2020-11-23 07:27:21 +00:00
class IgnorePing(logging.Filter):
def filter(self, record):
return 'GET /ping' not in record.getMessage()
LOG_DICT = {
2020-09-16 21:41:55 +00:00
'version': 1,
2020-11-23 07:27:21 +00:00
'formatters': {
'default': {
'format': '[%(asctime)s] [%(process)d] [%(levelname)7s] %(message)s',
},
},
'filters': {
'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,
},
},
2020-09-16 21:41:55 +00:00
'root': {
2021-11-11 00:17:44 +00:00
'level': 'DEBUG',
2020-09-16 21:41:55 +00:00
'handlers': ['wsgi']
}
2020-11-23 07:27:21 +00:00
}
2020-09-16 21:41:55 +00:00
2020-11-23 07:27:21 +00:00
logging.config.dictConfig(LOG_DICT)
2020-09-16 21:41:55 +00:00
logger = logging.getLogger(__name__)
logger.info('Logging enabled.')
2020-11-23 07:27:21 +00:00
from logging_tree import printout
printout()