完善日志系统
This commit is contained in:
+10
-6
@@ -3,12 +3,16 @@ from enum import Enum
|
||||
from core.eventbus import EventPrintLog, event_bus
|
||||
import config
|
||||
|
||||
|
||||
class LogLevel(Enum):
|
||||
DEBUG = "DEBUG"
|
||||
INFO = "INFO"
|
||||
WARNING = "WARNING"
|
||||
ERROR = "ERROR"
|
||||
CRITICAL = "CRITICAL"
|
||||
DEBUG = 0
|
||||
INFO = 1
|
||||
WARNING = 2
|
||||
ERROR = 3
|
||||
CRITICAL = 4
|
||||
|
||||
def __le__(self, other):
|
||||
return self.value <= other.value
|
||||
|
||||
class LogData:
|
||||
def __init__(self, level:LogLevel, message:str):
|
||||
@@ -19,4 +23,4 @@ def PrintLog(level:LogLevel, message:str):
|
||||
data = LogData(level, message)
|
||||
event_bus.publish(EventPrintLog, data)
|
||||
if config.console_log:
|
||||
print(f'{level.value} {message}')
|
||||
print(f'{level.name} {message}')
|
||||
|
||||
Reference in New Issue
Block a user