diff --git a/config.py b/config.py index 1f391fc..1d1a958 100644 --- a/config.py +++ b/config.py @@ -20,23 +20,21 @@ class Config(object): SECURITY_POST_LOGIN_VIEW = '/user/tenant' SECURITY_RECOVERABLE = True - - # flask-mailman settings MAIL_SERVER = 'mail.flow-it.net' MAIL_PORT = 465 MAIL_USE_TLS = True MAIL_USE_SSL = False - MAIL_DEFAULT_SENDER = 'eveAI Admin ' - + MAIL_DEFAULT_SENDER = ('eveAI Admin', 'eveai_admin@flow-it.net') class DevConfig(Config): DEVELOPMENT = True DEBUG = True + FLASK_DEBUG = True SQLALCHEMY_DATABASE_URI = 'postgresql+pg8000://josako@localhost:5432/eveAI' SQLALCHEMY_BINDS = {'public': 'postgresql+pg8000://josako@localhost:5432/eveAI'} - EXPLAIN_TEMPLATE_LOADING = True + EXPLAIN_TEMPLATE_LOADING = False # flask-mailman settings MAIL_USERNAME = 'eveai_super@flow-it.net' diff --git a/eveai_app/__init__.py b/eveai_app/__init__.py index 65f9d97..c5ec3bb 100644 --- a/eveai_app/__init__.py +++ b/eveai_app/__init__.py @@ -1,12 +1,16 @@ import logging import os from flask import Flask -from flask_security import SQLAlchemyUserDatastore +from flask_security import SQLAlchemyUserDatastore, current_user from werkzeug.middleware.proxy_fix import ProxyFix +import logging.config from .extensions import db, migrate, bootstrap, security, mail, login_manager from .models.user import User, Tenant, Role from .models.document import Document, DocumentLanguage, DocumentVersion +from logging_config import LOGGING + +# Create app def create_app(config_file=None): @@ -23,15 +27,22 @@ def create_app(config_file=None): except OSError: pass + logging.config.dictConfig(LOGGING) register_extensions(app) # Setup Flask-Security-Too user_datastore = SQLAlchemyUserDatastore(db, User, Role) security.init_app(app, user_datastore) + # Register Blueprints register_blueprints(app) if app.config['DEBUG'] is True: app.logger.setLevel(logging.DEBUG) + mail_logger = logging.getLogger('flask_mailman') + mail_logger.setLevel(logging.DEBUG) + + # Register API + register_api(app) return app diff --git a/eveai_app/templates/security/forgot_password.html b/eveai_app/templates/security/forgot_password_.html similarity index 100% rename from eveai_app/templates/security/forgot_password.html rename to eveai_app/templates/security/forgot_password_.html diff --git a/logging_config.py b/logging_config.py new file mode 100644 index 0000000..4ace9c8 --- /dev/null +++ b/logging_config.py @@ -0,0 +1,31 @@ +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'handlers': { + 'file': { + 'level': 'DEBUG', + 'class': 'logging.handlers.RotatingFileHandler', + 'filename': 'app.log', + 'maxBytes': 1024*1024*5, # 5MB + 'backupCount': 10, + 'formatter': 'standard', + }, + 'console': { + 'class': 'logging.StreamHandler', + 'level': 'DEBUG', + 'formatter': 'standard', + }, + }, + 'formatters': { + 'standard': { + 'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s' + }, + }, + 'loggers': { + '': { # root logger + 'handlers': ['file', 'console'], + 'level': 'DEBUG', + 'propagate': True + } + } +} \ No newline at end of file