🔀 Merge pull request #195

Fix: mirai adapter not escape tag in log
This commit is contained in:
Ju4tCode 2021-02-05 20:55:54 +08:00 committed by GitHub
commit 7232c89292
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,23 +20,29 @@ _AnyCallable = TypeVar("_AnyCallable", bound=Callable)
class Log: class Log:
_log = logger_wrapper('MIRAI')
@staticmethod
def _log(level: str, message: Any, exception: Optional[Exception] = None):
logger = logger_wrapper('MIRAI')
logger(level=level,
message=escape_tag(str(message)),
exception=exception)
@classmethod @classmethod
def info(cls, message: Any): def info(cls, message: Any):
cls._log('INFO', str(message)) cls._log('INFO', escape_tag(str(message)))
@classmethod @classmethod
def debug(cls, message: Any): def debug(cls, message: Any):
cls._log('DEBUG', str(message)) cls._log('DEBUG', escape_tag(str(message)))
@classmethod @classmethod
def warn(cls, message: Any): def warn(cls, message: Any):
cls._log('WARNING', str(message)) cls._log('WARNING', escape_tag(str(message)))
@classmethod @classmethod
def error(cls, message: Any, exception: Optional[Exception] = None): def error(cls, message: Any, exception: Optional[Exception] = None):
cls._log('ERROR', str(message), exception=exception) cls._log('ERROR', escape_tag(str(message)), exception=exception)
class ActionFailed(exception.ActionFailed): class ActionFailed(exception.ActionFailed):