From ce66e4ecc697c7a87e8e73d19eebbdd385fdf073 Mon Sep 17 00:00:00 2001 From: Anon Ray Date: Sun, 11 May 2014 03:47:43 +0530 Subject: [PATCH] Fix sample_config - Add missing values in sample_config.py - Moved to a RotatingFileHandler for logging --- swtstore/application.py | 7 +++++-- swtstore/sample_config.py | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/swtstore/application.py b/swtstore/application.py index 89fdc97..0d608e0 100644 --- 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 @@ def configure_logging(app): 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' diff --git a/swtstore/sample_config.py b/swtstore/sample_config.py index 216f883..d21d048 100644 --- a/swtstore/sample_config.py +++ b/swtstore/sample_config.py @@ -18,14 +18,16 @@ class DefaultConfig(): 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' -- 1.7.10.4