haldis/app/app.py

47 lines
1.3 KiB
Python
Raw Normal View History

2015-04-02 12:41:19 +02:00
import logging
from logging.handlers import TimedRotatingFileHandler
2015-03-31 20:15:22 +02:00
from flask import Flask
from flask.ext.bootstrap import Bootstrap, StaticCDN
from flask.ext.sqlalchemy import SQLAlchemy
2015-06-09 22:24:48 +02:00
from flask_debugtoolbar import DebugToolbarExtension
2015-03-31 20:15:22 +02:00
2015-06-09 16:47:11 +02:00
from airbrake import Airbrake, AirbrakeHandler
2015-03-31 20:15:22 +02:00
app = Flask(__name__)
app.config.from_object('config.Configuration')
Bootstrap(app)
# use our own bootstrap theme
app.extensions['bootstrap']['cdns']['bootstrap'] = StaticCDN()
db = SQLAlchemy(app)
2015-06-09 22:24:48 +02:00
toolbar = DebugToolbarExtension(app)
2015-03-31 16:29:28 +02:00
2015-03-31 00:06:09 +02:00
if not app.debug:
2015-04-02 12:41:19 +02:00
timedFileHandler = TimedRotatingFileHandler(app.config['LOGFILE'], when='midnight', backupCount=100)
2015-04-02 21:01:18 +02:00
timedFileHandler.setLevel(logging.DEBUG)
2015-06-09 16:47:11 +02:00
loglogger = logging.getLogger('werkzeug')
loglogger.setLevel(logging.DEBUG)
loglogger.addHandler(timedFileHandler)
2015-04-02 12:41:19 +02:00
app.logger.addHandler(timedFileHandler)
2015-06-09 16:47:11 +02:00
airbrakelogger = logging.getLogger('airbrake')
# Airbrake
airbrake = Airbrake(
project_id=app.config['AIRBRAKE_ID'],
api_key=app.config['AIRBRAKE_KEY']
)
# ugly hack to make this work for out errbit
2015-11-29 15:19:37 +01:00
airbrake._api_url = "http://errbit.awesomepeople.tv/api/v3/projects/{}/notices".format(airbrake.project_id)
2015-06-09 16:47:11 +02:00
airbrakelogger.addHandler(
AirbrakeHandler(airbrake=airbrake)
)
app.logger.addHandler(
AirbrakeHandler(airbrake=airbrake)
2016-09-10 15:49:52 +02:00
)