aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/__init__.py
blob: 3e7aad42d264bf9a3689303da825b28d0dd929b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# coding=utf-8
import logging
import os


# region Logging
# Get the log level from environment
log_level = os.environ.get("LOG_LEVEL", "info").upper()
formatter = logging.Formatter('[%(asctime)s] [%(levelname)s] %(message)s')

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=formatter, level=log_level)
# endregion