#!flask/bin/python
from app import app
-app.jinja_env.auto_reload = True
-app.config['TEMPLATES_AUTO_RELOAD'] = True
-app.run(debug=True)
+from config import ADMINS, MAIL_SERVER, MAIL_PORT, MAIL_USERNAME, MAIL_PASSWORD
+import logging
+
+app.debug = True
+
+if not app.debug:
+ from logging.handlers import SMTPHandler, RotatingFileHandler
+ credentials = None
+ if MAIL_USERNAME or MAIL_PASSWORD:
+ credentials = (MAIL_USERNAME, MAIL_PASSWORD)
+ mail_handler = SMTPHandler((MAIL_SERVER, MAIL_PORT), 'no-reply@' + MAIL_SERVER, ADMINS, 'PWP failure', credentials)
+ mail_handler.setLevel(logging.ERROR)
+ mail_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'))
+ app.logger.addHandler(mail_handler)
+
+ file_handler = RotatingFileHandler('log/pwp.log', 'a', 1 * 1024 * 1024, 10)
+ file_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'))
+ app.logger.addHandler(file_handler)
+ file_handler.setLevel(logging.DEBUG)
+else:
+# from flask_debugtoolbar import DebugToolbarExtension
+
+# toolbar = DebugToolbarExtension(app)
+ app.jinja_env.auto_reload = True
+ app.config['TEMPLATES_AUTO_RELOAD'] = True
+
+app.logger.setLevel(logging.DEBUG)
+app.logger.info('pwp startup')
+#from werkzeug.security import generate_password_hash
+#print (generate_password_hash('test', method='sha256'))
+app.run()