Skip to content

Commit

Permalink
Create the logger class file, outline the logging we want to have. We…
Browse files Browse the repository at this point in the history
… will be writing both verbose output as well as debugging information to a file based on command arguments.
  • Loading branch information
rowingdude committed Aug 16, 2024
1 parent 31cff95 commit 355cda3
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions analyze_mft/logger.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 355cda3

Please sign in to comment.