Commit ce66e4ecc697c7a87e8e73d19eebbdd385fdf073

Fix sample_config

  - Add missing values in sample_config.py
  - Moved to a RotatingFileHandler for logging
  • Diff rendering mode:
  • inline
  • side by side

swtstore/application.py

6from flask import Flask, request, jsonify, render_template, make_response, g6from flask import Flask, request, jsonify, render_template, make_response, g
7import os7import os
8import logging8import logging
9from logging.handlers import RotatingFileHandler
910
10from classes.database import db11from classes.database import db
11from config import DefaultConfig12from config import DefaultConfig
155 formatter = logging.Formatter('%(asctime)s %(levelname)s: %(message)s '155 formatter = logging.Formatter('%(asctime)s %(levelname)s: %(message)s '
156 '[in %(pathname)s:%(lineno)d]')156 '[in %(pathname)s:%(lineno)d]')
157157
158 # TODO: maybe we can use a RotatingFileHandler?
159 # Also error can be sent out via email. So we can also have a SMTPHandler?158 # Also error can be sent out via email. So we can also have a SMTPHandler?
160 log_handler = logging.StreamHandler()
159 log_file = app.config['LOG_FILE']
160 max_size = 1024 * 1024 * 20 # Max Size for a log file: 20MB
161 log_handler = RotatingFileHandler(log_file, maxBytes=max_size,
162 backupCount=10)
161163
162 if app.config.has_key('LOG_LEVEL'):164 if app.config.has_key('LOG_LEVEL'):
163 log_level = app.config['LOG_LEVEL'] or 'ERROR'165 log_level = app.config['LOG_LEVEL'] or 'ERROR'

swtstore/sample_config.py

18 SQLALCHEMY_DATABASE_URI =\18 SQLALCHEMY_DATABASE_URI =\
19 'dialect+driver://username:password@host:port/database'19 'dialect+driver://username:password@host:port/database'
2020
21 # Log level for the application
22 LOG_LEVEL = 'ERROR'
23
21 # sqlalchemy debug messages; turn to False in prdocution24 # sqlalchemy debug messages; turn to False in prdocution
22 SQLALCHEMY_ECHO = True #False25 SQLALCHEMY_ECHO = True #False
2326
24 #DEFAULT_MAIL_SENDER = 'support@swtr.us'27 #DEFAULT_MAIL_SENDER = 'support@swtr.us'
2528
26 # Configure your log paths29 # Configure your log paths
27 DEBUG_LOG = 'logs/debug.log'
28 ERROR_LOG = 'logs/error.log'
30 LOG_FILE = 'logs/swtstore.log'
2931
30 # The Mozilla Persona Verifier Host. Leave it as it is.32 # The Mozilla Persona Verifier Host. Leave it as it is.
31 MOZ_PERSONA_VERIFIER = 'https://verifier.login.persona.org/verify'33 MOZ_PERSONA_VERIFIER = 'https://verifier.login.persona.org/verify'