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': {
|
2022-06-03 00:34:35 +00:00
|
|
|
'level': 'INFO',
|
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()
|
|
|
|
|