--- a/swtstore/application.py +++ b/swtstore/application.py @@ -6,6 +6,7 @@ from flask import Flask, request, jsonify, render_template, make_response, g import os import logging +from logging.handlers import RotatingFileHandler from classes.database import db from config import DefaultConfig @@ -154,9 +155,11 @@ formatter = logging.Formatter('%(asctime)s %(levelname)s: %(message)s ' '[in %(pathname)s:%(lineno)d]') - # TODO: maybe we can use a RotatingFileHandler? # Also error can be sent out via email. So we can also have a SMTPHandler? - log_handler = logging.StreamHandler() + log_file = app.config['LOG_FILE'] + max_size = 1024 * 1024 * 20 # Max Size for a log file: 20MB + log_handler = RotatingFileHandler(log_file, maxBytes=max_size, + backupCount=10) if app.config.has_key('LOG_LEVEL'): log_level = app.config['LOG_LEVEL'] or 'ERROR' --- a/swtstore/sample_config.py +++ b/swtstore/sample_config.py @@ -18,14 +18,16 @@ SQLALCHEMY_DATABASE_URI =\ 'dialect+driver://username:password@host:port/database' + # Log level for the application + LOG_LEVEL = 'ERROR' + # sqlalchemy debug messages; turn to False in prdocution SQLALCHEMY_ECHO = True #False #DEFAULT_MAIL_SENDER = 'support@swtr.us' # Configure your log paths - DEBUG_LOG = 'logs/debug.log' - ERROR_LOG = 'logs/error.log' + LOG_FILE = 'logs/swtstore.log' # The Mozilla Persona Verifier Host. Leave it as it is. MOZ_PERSONA_VERIFIER = 'https://verifier.login.persona.org/verify'