mirror of
https://github.com/radio95-rnt/RadioPlayer.git
synced 2026-07-30 15:59:16 +02:00
fix log95
This commit is contained in:
@@ -12,10 +12,10 @@ except ModuleNotFoundError:
|
|||||||
class log95Levels(Enum):
|
class log95Levels(Enum):
|
||||||
DEBUG = 0
|
DEBUG = 0
|
||||||
VERBOSE = 1
|
VERBOSE = 1
|
||||||
INFO = 2
|
CRITICAL_ERROR = 2
|
||||||
WARN = 3
|
ERROR = 3
|
||||||
ERROR = 4
|
WARN = 4
|
||||||
CRITICAL_ERROR = 5
|
INFO = 5
|
||||||
|
|
||||||
def level_to_syslog(level: log95Levels):
|
def level_to_syslog(level: log95Levels):
|
||||||
match level:
|
match level:
|
||||||
@@ -36,7 +36,6 @@ class log95:
|
|||||||
self.level = int(level.value)
|
self.level = int(level.value)
|
||||||
self.output = output
|
self.output = output
|
||||||
def log(self, level: log95Levels, *args:str, seperator=" ") -> None:
|
def log(self, level: log95Levels, *args:str, seperator=" ") -> None:
|
||||||
if level.value > self.level: return
|
|
||||||
we_have_color = "colorama" in sys.modules
|
we_have_color = "colorama" in sys.modules
|
||||||
def level_to_str(_level: log95Levels, _color: bool) -> LiteralString | str:
|
def level_to_str(_level: log95Levels, _color: bool) -> LiteralString | str:
|
||||||
if _color:
|
if _color:
|
||||||
@@ -51,7 +50,7 @@ class log95:
|
|||||||
match _level:
|
match _level:
|
||||||
case log95Levels.CRITICAL_ERROR: return "CRITICAL"
|
case log95Levels.CRITICAL_ERROR: return "CRITICAL"
|
||||||
case _: return _level.name
|
case _: return _level.name
|
||||||
self.output.write(f"[{self.tag}] ({level_to_str(level, we_have_color)}) @ ({datetime.datetime.now().strftime('%d.%m.%Y %H:%M:%S.%f')}) - {seperator.join(args)}{os.linesep}")
|
if level.value > self.level: self.output.write(f"[{self.tag}] ({level_to_str(level, we_have_color)}) @ ({datetime.datetime.now().strftime('%d.%m.%Y %H:%M:%S.%f')}) - {seperator.join(args)}{os.linesep}")
|
||||||
if isinstance(self.output, SyslogTextIO): self.output.syslog(level, seperator.join(args))
|
if isinstance(self.output, SyslogTextIO): self.output.syslog(level, seperator.join(args))
|
||||||
def debug(self, *args:str, seperator=" ") -> None:
|
def debug(self, *args:str, seperator=" ") -> None:
|
||||||
self.log(log95Levels.DEBUG, *args, seperator)
|
self.log(log95Levels.DEBUG, *args, seperator)
|
||||||
|
|||||||
Reference in New Issue
Block a user