Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions users/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
from users.database import db, migrate


APP = Flask(__name__)
# Load configuration from any possible means.
AppConfig(APP, default_settings="users.default_config")


def add_handler_once(logger, handler):
"""A helper to add a handler to a logger, ensuring there are no duplicates.

Expand Down Expand Up @@ -45,12 +50,12 @@ def setup_logger():
# create formatter that will be added to the handlers
formatter = logging.Formatter(
'%(asctime)s - %(name)s - %(levelname)s - %(message)s')
temp_dir = '/tmp'
log_dir = APP.config['LOG_DIR']
# so e.g. jenkins can override log dir.
if 'USER_MAP_LOGFILE' in os.environ:
file_name = os.environ['USER_MAP_LOGFILE']
else:
file_name = os.path.join(temp_dir, 'user-map.log')
file_name = os.path.join(log_dir, 'user-map.log')
file_handler = logging.FileHandler(file_name)
file_handler.setLevel(handler_level)
# create console handler with a higher log level
Expand All @@ -68,10 +73,6 @@ def setup_logger():
setup_logger()
LOGGER = logging.getLogger('user_map')

APP = Flask(__name__)

# Load configuration from any possible means.
AppConfig(APP, default_settings="users.default_config")

# Mailer
mail = Mail(APP)
Expand Down
3 changes: 3 additions & 0 deletions users/default_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
shadow='/static/img/marker-shadow.png'
)

# Directory location for log file
LOG_DIR = '/tmp'

# By default it uses postgres, hence you'll need to ``psycopg2``.
# If you're using MySQL, refer to
# http://docs.sqlalchemy.org/en/rel_0_9/core/engines.html
Expand Down