From 808bef5f5d0e5d17ac8428eb205e8f5ac57c5aab Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Fri, 30 Oct 2020 22:00:30 +0000 Subject: [PATCH] Add LoggingManager --- helpers/__init__.py | 0 helpers/logging_manager.py | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 helpers/__init__.py create mode 100644 helpers/logging_manager.py diff --git a/helpers/__init__.py b/helpers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/helpers/logging_manager.py b/helpers/logging_manager.py new file mode 100644 index 0000000..b3c60e6 --- /dev/null +++ b/helpers/logging_manager.py @@ -0,0 +1,25 @@ +import logging +from helpers.os_environment import resolve_external_file_path + + +class LoggingManager(): + + logger = None + + def __init__(self, name): + self.logger = logging.getLogger(name) + + logging.basicConfig( + filename=resolve_external_file_path("/logs/" + name + ".txt"), + format='%(asctime)s | %(levelname)s | %(message)s', + level=logging.INFO, + filemode='a' + ) + self.logger.info("Logger Started.") + + def __del__(self): + logging.shutdown() + + @property + def log(self): + return self.logger