Remaining initial commit
This commit is contained in:
parent
5e191563f6
commit
5e9f3869dc
6 changed files with 336 additions and 4 deletions
60
src/logger.pyx
Normal file
60
src/logger.pyx
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
"""
|
||||
Author: Jose Stovall | oitsjustjose
|
||||
"""
|
||||
|
||||
from typing import Union
|
||||
from pip._vendor.colorama import Fore
|
||||
|
||||
|
||||
def _with_color(msg: str, color: str) -> None:
|
||||
"""
|
||||
Prints anything with some color
|
||||
"""
|
||||
print(f"{color}{msg}{Fore.RESET}")
|
||||
|
||||
|
||||
class Logger:
|
||||
"""
|
||||
A simple logging class
|
||||
Arguments:
|
||||
name (str|None): the name of the logger, if any
|
||||
"""
|
||||
|
||||
def __init__(self, name: Union[str, None] = None):
|
||||
self._name = name
|
||||
|
||||
def info(self, msg: str) -> None:
|
||||
"""
|
||||
Prints out a message to log
|
||||
"""
|
||||
if self._name:
|
||||
_with_color(f"[{self._name}]: {msg}", Fore.WHITE)
|
||||
else:
|
||||
_with_color(msg, Fore.WHITE)
|
||||
|
||||
def success(self, msg: str) -> None:
|
||||
"""
|
||||
Prints out a successfully finished event/msg
|
||||
"""
|
||||
if self._name:
|
||||
_with_color(f"[{self._name}]: {msg}", Fore.GREEN)
|
||||
else:
|
||||
_with_color(msg, Fore.GREEN)
|
||||
|
||||
def warn(self, msg: str) -> None:
|
||||
"""
|
||||
Prints out a message as a warning
|
||||
"""
|
||||
if self._name:
|
||||
_with_color(f"[{self._name}]: {msg}", Fore.YELLOW)
|
||||
else:
|
||||
_with_color(msg, Fore.YELLOW)
|
||||
|
||||
def err(self, msg: str) -> None:
|
||||
"""
|
||||
Prints out a message as an error
|
||||
"""
|
||||
if self._name:
|
||||
_with_color(f"[{self._name}]: {msg}", Fore.RED)
|
||||
else:
|
||||
_with_color(msg, Fore.RED)
|
||||
Loading…
Reference in a new issue