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"

class LogData:
    def __init__(self, level:LogLevel, message:str):
        self.level = level
        self.message = message

def PrintLog(level:LogLevel, message:str):
    data = LogData(level, message)
    event_bus.publish(EventPrintLog, data)
    if config.console_log:
        print(f'{level.value} {message}')
