Made code more readable
This commit is contained in:
parent
e62a61e565
commit
faf0b2973c
1 changed files with 4 additions and 4 deletions
|
@ -40,7 +40,7 @@ class ConfigurationManager:
|
||||||
def _get_default_config(self):
|
def _get_default_config(self):
|
||||||
return {
|
return {
|
||||||
"debug": 1,
|
"debug": 1,
|
||||||
"logging": 1,
|
"logging": 0,
|
||||||
"loglevel": 3,
|
"loglevel": 3,
|
||||||
"logfile": "petcard.log",
|
"logfile": "petcard.log",
|
||||||
"display": "SSD1306",
|
"display": "SSD1306",
|
||||||
|
@ -55,8 +55,8 @@ class ConfigurationManager:
|
||||||
# Handles logging functionality with timestamp formatting
|
# Handles logging functionality with timestamp formatting
|
||||||
class Logger:
|
class Logger:
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.log_level = config.get("loglevel", 0) == 3
|
self.log_level = config.get("loglevel")
|
||||||
self.logging_enabled = config.get("logging", 0) == 1
|
self.logging_enabled = config.get("logging")
|
||||||
self.log_file = config.get("logfile", "system.log")
|
self.log_file = config.get("logfile", "system.log")
|
||||||
|
|
||||||
def log(self, message, log_level, ignore_console=False):
|
def log(self, message, log_level, ignore_console=False):
|
||||||
|
@ -77,7 +77,7 @@ class Logger:
|
||||||
if not ignore_console:
|
if not ignore_console:
|
||||||
print(formatted_message)
|
print(formatted_message)
|
||||||
|
|
||||||
if self.logging_enabled:
|
if self.logging_enabled == 1:
|
||||||
self._write_to_file(formatted_message)
|
self._write_to_file(formatted_message)
|
||||||
|
|
||||||
def _get_timestamp(self):
|
def _get_timestamp(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue