You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.7 KiB
Python

4 years ago
import logging
import requests
4 years ago
from logging.config import dictConfig
from flask import render_template
4 years ago
from app.factory import create_app
from app.library.cache import cache
4 years ago
app = create_app()
4 years ago
@app.errorhandler(requests.exceptions.ConnectionError)
def request_connection_error(e):
key_name = 'request_connection_error'
data = cache.redis.get(key_name)
if not data:
app.logger.error(f'HTTP connection error: {e}')
cache.store_data(key_name, 10, 1)
return render_template('error.html'), 500
dictConfig({
"version": 1,
"disable_existing_loggers": True,
"formatters": {
"default": {
"format": "[%(asctime)s] %(levelname)s in %(module)s: %(message)s",
},
"access": {
"format": "%(message)s",
}
},
"handlers": {
"console": {
"level": "INFO",
"class": "logging.StreamHandler",
"formatter": "default",
"stream": "ext://sys.stdout",
},
"mattermost": {
"class": "app.factory.MattermostHandler",
"formatter": "default",
"level": "ERROR",
}
},
"loggers": {
"gunicorn.error": {
"handlers": ["console"] if app.debug else ["console", "mattermost"],
"level": "INFO",
"propagate": False,
},
"gunicorn.access": {
"handlers": ["console"] if app.debug else ["console"],
"level": "INFO",
"propagate": False,
}
},
"root": {
"level": "DEBUG" if app.debug else "INFO",
"handlers": ["console"] if app.debug else ["console", "mattermost"],
}
})
4 years ago
if __name__ == '__main__':
app.run()