-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
31cff95
commit 355cda3
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |