diff options
-rw-r--r-- | bot/__init__.py | 21 | ||||
-rw-r--r-- | bot/constants.py | 4 |
2 files changed, 25 insertions, 0 deletions
diff --git a/bot/__init__.py b/bot/__init__.py index 95ea77d96..f17404572 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -1,8 +1,29 @@ # coding=utf-8 import ast +import logging +import sys +from logging import StreamHandler +from logging.handlers import SysLogHandler import discord.ext.commands.view +from bot.constants import PAPERTRAIL_ADDRESS, PAPERTRAIL_PORT + + +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 Bot: | %(name)15s | %(levelname)8s | %(message)s", + datefmt="%b %d %H:%M:%S", + level=logging.INFO, + handlers=logging_handlers +) + def _skip_string(self, string: str) -> bool: """ diff --git a/bot/constants.py b/bot/constants.py index 3c8fcc266..9878eb716 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -48,3 +48,7 @@ TAG_COOLDOWN = 60 # Per channel, per tag GREEN_CHEVRON = "<:greenchevron:418104310329769993>" RED_CHEVRON = "<:redchevron:418112778184818698>" WHITE_CHEVRON = "<:whitechevron:418110396973711363>" + +# PaperTrail logging +PAPERTRAIL_ADDRESS = os.environ.get("PAPERTRAIL_ADDRESS") +PAPERTRAIL_PORT = int(os.environ.get("PAPERTRAIL_PORT", 0)) |