From 355cda3cffae27990d9e24a7ba9ef36170e38988 Mon Sep 17 00:00:00 2001 From: Benjamin Cance Date: Fri, 16 Aug 2024 09:36:32 -0400 Subject: [PATCH] Create the logger class file, outline the logging we want to have. We will be writing both verbose output as well as debugging information to a file based on command arguments. --- analyze_mft/logger.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 analyze_mft/logger.py diff --git a/analyze_mft/logger.py b/analyze_mft/logger.py new file mode 100644 index 0000000..666f1a3 --- /dev/null +++ b/analyze_mft/logger.py @@ -0,0 +1,34 @@ +from .common_imports import * + +class Logger: + def __init__(self, options): + self.options = options + self.setup_logging() + + def setup_logging(self): + log_level = logging.DEBUG if self.options.debug else logging.INFO + logging.basicConfig(level=log_level, + format='%(asctime)s - %(levelname)s - %(message)s', + filename='analyzeMFT.log' if self.options.debug else None) + if self.options.verbose: + console = logging.StreamHandler() + console.setLevel(logging.INFO) + formatter = logging.Formatter('%(levelname)s - %(message)s') + console.setFormatter(formatter) + logging.getLogger('').addHandler(console) + + @staticmethod + def info(message): + logging.info(message) + + @staticmethod + def debug(message): + logging.debug(message) + + @staticmethod + def warning(message): + logging.warning(message) + + @staticmethod + def error(message): + logging.error(message) \ No newline at end of file