diff --git a/logger.py b/logger.py deleted file mode 100644 index c95e92c..0000000 --- a/logger.py +++ /dev/null @@ -1,70 +0,0 @@ -from enum import Enum -import datetime - -class Logger: - printer_fn = print - - class Colour_Code(Enum): - ENDC = '\033[0m' - BOLD = '\033[1m' - UNDERLINE = '\033[4m' - RED = '\033[91m' - GREEN = '\033[92m' - YELLOW = '\033[93m' - BLUE = '\033[94m' - PURPLE = '\033[95m' - CYAN = '\033[96m' - - class Log_Level(Enum): - INFO = 0 - SUCCESS = 1 - WARN = 2 - ERROR = 3 - CRITICAL = 4 - - log_level = Log_Level.INFO - - def __init__(self, name): - self.name = name - - def _log_normal(self, s: str, c: Colour_Code) -> None: - Logger.printer_fn(f"{c.value}[{self.name}: {datetime.datetime.now()}] {s}{self.Colour_Code.ENDC.value}") - - def _log_bold(self, s: str, c: Colour_Code) -> None: - Logger.printer_fn(f"{self.Colour_Code.BOLD.value}{c.value}[{self.name}: {datetime.datetime.now()}] {s}{self.Colour_Code.ENDC.value}") - - def _log_underlined(self, s: str, c: Colour_Code) -> None: - Logger.printer_fn(f"{self.Colour_Code.UNDERLINE.value}{c.value}[{self.name}: {datetime.datetime.now()}] {s}{self.Colour_Code.ENDC.value}") - - def _log_bold_underlined(self, s: str, c: Colour_Code) -> None: - Logger.printer_fn(f"{self.Colour_Code.BOLD.value}{self.Colour_Code.UNDERLINE.value}{c.value}[{self.name}: {datetime.datetime.now()}] {s}{self.Colour_Code.ENDC.value}") - - def info(self, s: str) -> None: - if(self.log_level.value <= self.Log_Level.INFO.value): - self._log_normal(s, self.Colour_Code.BLUE) - - def info_header(self, s: str) -> None: - if(self.log_level.value <= self.Log_Level.INFO.value): - self._log_bold(s, self.Colour_Code.CYAN) - - def success(self, s: str) -> None: - if(self.log_level.value <= self.Log_Level.SUCCESS.value): - self._log_bold_underlined(s, self.Colour_Code.GREEN) - - def warn(self, s: str) -> None: - if(self.log_level.value <= self.Log_Level.WARN.value): - self._log_bold(s, self.Colour_Code.YELLOW) - - def error(self, s: str) -> None: - if(self.log_level.value <= self.Log_Level.ERROR.value): - self._log_bold(s, self.Colour_Code.RED) - - def critical(self, s: str) -> None: - if(self.log_level.value <= self.Log_Level.CRITICAL.value): - self._log_bold_underlined(s, self.Colour_Code.RED) - -def set_log_level(l: Logger.Log_Level): - Logger.log_level = l - -def set_printer(fn): - Logger.printer_fn = fn \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 6ae0193..f682456 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = swarmnet -version = 0.0.2 +version = 0.0.3 author = Toby Godfrey author_email = swarmnet@tgodfrey.com description = A gossip-based swarm communication library diff --git a/src/swarmnet/msg_parser.py b/src/swarmnet/msg_parser.py index b689602..7f0fc69 100644 --- a/src/swarmnet/msg_parser.py +++ b/src/swarmnet/msg_parser.py @@ -26,4 +26,10 @@ def parse_msg(self) -> None: log.info(f"Parse thread spawned to parse {cmd} command") except KeyError: - log.error(f"No registered parser for command {cmd}") \ No newline at end of file + log.error(f"No registered parser for command {cmd}") + log.error("Registered parsers exist for commands:") + for c in self.fn_map.keys(): + if(c == "JOIN"): + continue + + log.error(c) \ No newline at end of file