Added logging

This commit is contained in:
Feliciaan De Palmenaer 2015-04-02 12:41:19 +02:00
parent d4f129cd35
commit 7ce3642ef8
2 changed files with 10 additions and 3 deletions

View file

@ -1,3 +1,5 @@
import logging
from logging.handlers import TimedRotatingFileHandler
from flask import Flask from flask import Flask
from flask.ext.bootstrap import Bootstrap, StaticCDN from flask.ext.bootstrap import Bootstrap, StaticCDN
from flask.ext.sqlalchemy import SQLAlchemy from flask.ext.sqlalchemy import SQLAlchemy
@ -27,3 +29,9 @@ class PrefixFix(object):
if not app.debug: if not app.debug:
app.wsgi_app = PrefixFix(app.wsgi_app, '/james') app.wsgi_app = PrefixFix(app.wsgi_app, '/james')
timedFileHandler = TimedRotatingFileHandler(app.config['LOGFILE'], when='midnight', backupCount=100)
timedFileHandler.setLevel(logging.INFO)
logger = logging.getLogger('werkzeug')
logger.addHandler(timedFileHandler)
app.logger.addHandler(timedFileHandler)

View file

@ -1,6 +1,6 @@
from views import * from views import *
from app import app, db from app import app, db, logger
from admin import admin from admin import admin
from login import login_manager from login import login_manager
@ -9,6 +9,5 @@ from forms import *
from utils import * from utils import *
from views import * from views import *
if __name__ == '__main__': if __name__ == '__main__':
app.run(host='0.0.0.0', port=80) app.run(host='0.0.0.0')