mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-10-21 16:27:15 +08:00
🐛 日志转义 #422
This commit is contained in:
parent
2f7118a0c2
commit
10499d1e33
@ -1,6 +1,7 @@
|
||||
from typing import Dict
|
||||
|
||||
from nonebot import logger as nb_logger
|
||||
from nonebot.utils import escape_tag
|
||||
|
||||
|
||||
class logger:
|
||||
@ -10,20 +11,20 @@ class logger:
|
||||
|
||||
@staticmethod
|
||||
def info(command: str, info: str = '', param: Dict[str, any] = None, result: str = '', result_type: bool = True):
|
||||
param_str = ' '.join([f'{k}<m>{v}</m>' for k, v in param.items()]) if param else ''
|
||||
result_str = f'<g>{result}</g>' if result_type else f'<r>{result}</r>' if result else ''
|
||||
param_str = ' '.join([f'{k}<m>{escape_tag(v)}</m>' for k, v in param.items()]) if param else ''
|
||||
result_str = f'<g>{escape_tag(result)}</g>' if result_type else f'<r>{escape_tag(result)}</r>' if result else ''
|
||||
nb_logger.opt(colors=True).info(f'<u><y>[{command}]</y></u>{info}{param_str}{result_str}')
|
||||
|
||||
@staticmethod
|
||||
def success(command: str, info: str = '', param: Dict[str, any] = None, result: str = ''):
|
||||
param_str = ' '.join([f'{k}<m>{v}</m>' for k, v in param.items()]) if param else ''
|
||||
result_str = f'<g>{result}</g>' if result else ''
|
||||
param_str = ' '.join([f'{k}<m>{escape_tag(v)}</m>' for k, v in param.items()]) if param else ''
|
||||
result_str = f'<g>{escape_tag(result)}</g>' if result else ''
|
||||
nb_logger.opt(colors=True).success(f'<u><y>[{command}]</y></u>{info}{param_str}{result_str}')
|
||||
|
||||
@staticmethod
|
||||
def warning(command: str, info: str = '', action: str = ''):
|
||||
nb_logger.opt(colors=True).warning(f'<u><y>[{command}]</y></u>{info}<m>{action}</m>')
|
||||
nb_logger.opt(colors=True).warning(f'<u><y>[{command}]</y></u>{escape_tag(info)}<m>{escape_tag(action)}</m>')
|
||||
|
||||
@staticmethod
|
||||
def debug(command: str, info: str):
|
||||
nb_logger.opt(colors=True).debug(f'<u><y>[{command}]</y></u>{info}')
|
||||
nb_logger.opt(colors=True).debug(f'<u><y>[{command}]</y></u>{escape_tag(info)}')
|
||||
|
Loading…
Reference in New Issue
Block a user