Skip to content

Commit

Permalink
Add error logging method to Logger class and bump version to 2.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
sexfrance committed Dec 11, 2024
1 parent d6b5ae8 commit f698dd4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions logmagix/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ def failure(self, message: str, start: int = None, end: int = None, level: str =
print(log_message)
self._write_to_log(log_message)

def error(self, message: str, start: int = None, end: int = None, level: str = "Error") -> None:
if self._should_log(LogLevel.FAILURE):
timer = f" {self.BRIGHT_MAGENTA}In{self.WHITE} -> {self.BRIGHT_MAGENTA}{str(end - start)[:5]} Seconds {Fore.RESET}" if start and end else ""
log_message = self.message3(f"{self.RED}{level}", f"{self.RED}{message}", start, end) + timer
print(log_message)
self._write_to_log(log_message)

def warning(self, message: str, start: int = None, end: int = None, level: str = "Warning") -> None:
if self._should_log(LogLevel.WARNING):
timer = f" {self.BRIGHT_MAGENTA}In{self.WHITE} -> {self.BRIGHT_MAGENTA}{str(end - start)[:5]} Seconds {Fore.RESET}" if start and end else ""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="logmagix",
version="2.0.7",
version="2.0.8",
packages=find_packages(),
install_requires=["colorama", "pystyle"],
author="Sexfrance",
Expand Down

0 comments on commit f698dd4

Please sign in to comment.