diff --git a/config.py b/config.py index 7c40987c3..47cab7331 100644 --- a/config.py +++ b/config.py @@ -99,12 +99,26 @@ def init_app(cls, app): app.logger.addHandler(file_handler) +class UnixConfig(ProductionConfig): + @classmethod + def init_app(cls, app): + ProductionConfig.init_app(app) + + # log to syslog + import logging + from logging.handlers import SysLogHandler + syslog_handler = SysLogHandler() + syslog_handler.setLevel(logging.INFO) + app.logger.addHandler(syslog_handler) + + config = { 'development': DevelopmentConfig, 'testing': TestingConfig, 'production': ProductionConfig, 'heroku': HerokuConfig, 'docker': DockerConfig, + 'unix': UnixConfig, 'default': DevelopmentConfig } diff --git a/flasky.py b/flasky.py index a92e41a26..a2ec114ff 100644 --- a/flasky.py +++ b/flasky.py @@ -1,4 +1,9 @@ import os +from dotenv import load_dotenv + +dotenv_path = os.path.join(os.path.dirname(__file__), '.env') +if os.path.exists(dotenv_path): + load_dotenv(dotenv_path) COV = None if os.environ.get('FLASK_COVERAGE'): diff --git a/requirements/common.txt b/requirements/common.txt index 2d1b98240..8cbd6cb8d 100644 --- a/requirements/common.txt +++ b/requirements/common.txt @@ -20,6 +20,7 @@ Mako==1.0.7 Markdown==2.6.8 MarkupSafe==1.1.1 python-dateutil==2.6.1 +python-dotenv==0.6.5 python-editor==1.0.3 six==1.10.0 SQLAlchemy==1.1.11