From 17774ae0e252cecf321ec938bda3fbbde23c56a6 Mon Sep 17 00:00:00 2001 From: Zed Date: Thu, 2 Mar 2023 17:48:35 -0600 Subject: [PATCH] Add logging --- game/base.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/game/base.py b/game/base.py index a57ccbe..5074ec8 100644 --- a/game/base.py +++ b/game/base.py @@ -4,6 +4,8 @@ # pylint: disable=missing-module-docstring +import logging + from database.models import database, GameModel as Game @@ -24,6 +26,18 @@ class BaseGameManager: # Discord client instance self.discord = None + logger = logging.getLogger() + console = logging.StreamHandler() + + format_str = '%(asctime)s\t%(levelname)s -- %(processName)s %(filename)s:%(lineno)s -- %(message)s' + console.setFormatter(logging.Formatter(format_str)) + + logger.addHandler(console) + + logger.setLevel(logging.DEBUG) + + self.logger = logger + def __enter__(self): """ Allows use of `with Game() as game` for try/except statements