from loguru import logger as _loguru_logger
import sys

__all__ = ['logger']


class RpaLogger:
    def __init__(self):
        # 初始化配置 loguru
        _loguru_logger.remove()
        _loguru_logger.add(sys.stdout, level="DEBUG",
                           format="<green>{time}</green> | <level>{level}</level> | <cyan>{message}</cyan>")
        self._logger = _loguru_logger

    def debug(self, message, *args, **kwargs):
        self._logger.debug(message, *args, **kwargs)

    def info(self, message, *args, **kwargs):
        self._logger.info(message, *args, **kwargs)

    def warning(self, message, *args, **kwargs):
        self._logger.warning(message, *args, **kwargs)

    def error(self, message, *args, **kwargs):
        self._logger.error(message, *args, **kwargs)

    def exception(self, message, *args, **kwargs):
        self._logger.exception(message, *args, **kwargs)

    def log(self, level, message, *args, **kwargs):
        self._logger.log(level, message, *args, **kwargs)


# 单例实例
logger = RpaLogger()
