Commit ce66e4ecc697c7a87e8e73d19eebbdd385fdf073
Fix sample_config
- Add missing values in sample_config.py
- Moved to a RotatingFileHandler for logging
| | | | 6 | from flask import Flask, request, jsonify, render_template, make_response, g | 6 | from flask import Flask, request, jsonify, render_template, make_response, g |
---|
7 | import os | 7 | import os |
---|
8 | import logging | 8 | import logging |
---|
| | 9 | from logging.handlers import RotatingFileHandler |
---|
9 | | 10 | |
---|
10 | from classes.database import db | 11 | from classes.database import db |
---|
11 | from config import DefaultConfig | 12 | from 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]') |
---|
157 | | 157 | |
---|
158 | # TODO: maybe we can use a RotatingFileHandler? | | # 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() | | 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) |
---|
161 | | 163 | |
---|
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' |
---|
| | | | 18 | SQLALCHEMY_DATABASE_URI =\ | 18 | SQLALCHEMY_DATABASE_URI =\ |
---|
19 | 'dialect+driver://username:password@host:port/database' | 19 | 'dialect+driver://username:password@host:port/database' |
---|
20 | | 20 | |
---|
| | 21 | # Log level for the application |
---|
| | 22 | LOG_LEVEL = 'ERROR' |
---|
| | 23 | |
---|
21 | # sqlalchemy debug messages; turn to False in prdocution | 24 | # sqlalchemy debug messages; turn to False in prdocution |
---|
22 | SQLALCHEMY_ECHO = True #False | 25 | SQLALCHEMY_ECHO = True #False |
---|
23 | | 26 | |
---|
24 | #DEFAULT_MAIL_SENDER = 'support@swtr.us' | 27 | #DEFAULT_MAIL_SENDER = 'support@swtr.us' |
---|
25 | | 28 | |
---|
26 | # Configure your log paths | 29 | # Configure your log paths |
---|
27 | DEBUG_LOG = 'logs/debug.log' | | DEBUG_LOG = 'logs/debug.log' |
---|
28 | ERROR_LOG = 'logs/error.log' | | ERROR_LOG = 'logs/error.log' |
---|
| | 30 | LOG_FILE = 'logs/swtstore.log' | 29 | | 31 | |
---|
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' |
---|