diff options
author | 2018-03-13 00:22:33 +0100 | |
---|---|---|
committer | 2018-03-13 00:22:33 +0100 | |
commit | 5676b6495a9e07cf46a93e6939b88bda9eda44ba (patch) | |
tree | 81b4aac353a3307ff82fe81ae3be54bb42d69ee4 /pysite/__init__.py | |
parent | Minor bugfix to allow tag.delete to return success as False if the tag doesn'... (diff) | |
parent | Logging fixes (diff) |
Merge branch 'master' of github.com:discord-python/site
Diffstat (limited to 'pysite/__init__.py')
-rw-r--r-- | pysite/__init__.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/pysite/__init__.py b/pysite/__init__.py index a87e79d4..f807eaf4 100644 --- a/pysite/__init__.py +++ b/pysite/__init__.py @@ -1,7 +1,11 @@ # coding=utf-8 import logging import os +from logging import StreamHandler +from logging.handlers import SysLogHandler +import sys +from pysite.constants import PAPERTRAIL_ADDRESS, PAPERTRAIL_PORT # region Logging # Get the log level from environment @@ -12,6 +16,17 @@ if hasattr(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) +logging_handlers = [] + +if PAPERTRAIL_ADDRESS: + logging_handlers.append(SysLogHandler(address=(PAPERTRAIL_ADDRESS, PAPERTRAIL_PORT))) + +logging_handlers.append(StreamHandler(stream=sys.stderr)) + +logging.basicConfig( + format="%(asctime)s pd.beardfist.com Site: | %(name)30s | %(levelname)8s | %(message)s", + datefmt="%b %d %H:%M:%S", + level=log_level, + handlers=logging_handlers +) # endregion |