完善日志系统

This commit is contained in:
2025-11-25 17:13:40 +08:00
parent 81da3fe013
commit 4787011177
5 changed files with 36 additions and 17 deletions
+10 -6
View File
@@ -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}')