diff options
author | 2018-02-18 11:24:18 +0000 | |
---|---|---|
committer | 2018-02-18 11:24:18 +0000 | |
commit | ed0603857c2c839c19b7784cd00e0731e57364be (patch) | |
tree | ce12a9d5073a364a027665166626344987690aaa /pysite/__init__.py | |
parent | Rename "Websocket" to "WS" to avoid confusion with the gevents-websocket WebS... (diff) | |
parent | attempt to fix stacktrace when initialising logger (#17) (diff) |
Merge remote-tracking branch 'origin/master'
# Conflicts:
# pysite/views/ws/echo.py
Diffstat (limited to 'pysite/__init__.py')
-rw-r--r-- | pysite/__init__.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/pysite/__init__.py b/pysite/__init__.py index 9bad5790..a87e79d4 100644 --- a/pysite/__init__.py +++ b/pysite/__init__.py @@ -1 +1,17 @@ # coding=utf-8 +import logging +import os + + +# region Logging +# Get the log level from environment +log_level = os.environ.get("LOG_LEVEL", "info").upper() + +if hasattr(logging, log_level): + log_level = getattr(logging, log_level) +else: + raise RuntimeError("LOG_LEVEL environment variable has an invalid value.") + +# This handler will ensure we log to stdout and stderr +logging.basicConfig(format='[%(asctime)s] [%(levelname)s] %(message)s', level=log_level) +# endregion |