logger
This commit is contained in:
parent
86667fb264
commit
04470accef
3 changed files with 11 additions and 7 deletions
|
@ -9,6 +9,7 @@ from core.bots.aiocqhttp.client import bot
|
|||
from core.bots.aiocqhttp.tasks import MessageTaskManager, FinishedTasks
|
||||
from core.elements import Plain, Image, MessageSession as MS, MsgInfo, Session, Voice, FetchTarget as FT
|
||||
from core.elements.others import confirm_command
|
||||
from core.logger import Logger
|
||||
from database import BotDBUtil
|
||||
import html
|
||||
|
||||
|
@ -45,6 +46,7 @@ class MessageSession(MS):
|
|||
else:
|
||||
msg = msg + MessageSegment.text('发生错误:机器人尝试发送非法消息链,请联系机器人开发者解决问题。'
|
||||
'\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=')
|
||||
Logger.info(f'[Bot] -> [{self.target.targetId}]: {msg}')
|
||||
if self.target.targetFrom == 'QQ|Group':
|
||||
send = await bot.send_group_msg(group_id=self.session.target, message=msg)
|
||||
else:
|
||||
|
|
|
@ -30,21 +30,23 @@ class Logginglogger(AbstractLogger):
|
|||
format=fmt,
|
||||
level=logging.INFO if not kwargs.get("debug") else logging.DEBUG
|
||||
)
|
||||
self.log = logging.getLogger('akaribot.logger')
|
||||
self.log.setLevel(logging.INFO)
|
||||
|
||||
def info(self, msg):
|
||||
return logging.info(msg)
|
||||
return self.log.info(msg)
|
||||
|
||||
def error(self, msg):
|
||||
return logging.error(msg)
|
||||
return self.log.error(msg)
|
||||
|
||||
def debug(self, msg):
|
||||
return logging.debug(msg)
|
||||
return self.log.debug(msg)
|
||||
|
||||
def warn(self, msg):
|
||||
return logging.warning(msg)
|
||||
return self.log.warning(msg)
|
||||
|
||||
def exception(self, msg):
|
||||
return logging.exception(msg)
|
||||
return self.log.exception(msg)
|
||||
|
||||
|
||||
Logger = Logginglogger()
|
||||
|
|
|
@ -22,7 +22,7 @@ async def parser(msg: MessageSession):
|
|||
if senderInfo.query.isInBlackList and not senderInfo.query.isInWhiteList or len(display) == 0:
|
||||
return
|
||||
if display[0] in command_prefix: # 检查消息前缀
|
||||
Logger.info(display)
|
||||
Logger.info(f'[{msg.target.senderId}{f" ({msg.target.targetId})" if msg.target.targetFrom != msg.target.senderFrom else ""}] -> [Bot]: {display}')
|
||||
command = re.sub(r'^' + display[0], '', display)
|
||||
command_list = remove_ineffective_text(command_prefix, command.split('&&')) # 并行命令处理
|
||||
if len(command_list) > 5 and not senderInfo.query.isSuperUser:
|
||||
|
@ -72,7 +72,7 @@ async def parser(msg: MessageSession):
|
|||
async with msg.Typing(msg):
|
||||
await Modules[command_first_word].function(msg) # 将dict传入下游模块
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
Logger.error(traceback.format_exc())
|
||||
await msg.sendMessage('执行命令时发生错误,请报告机器人开发者:\n' + str(e) + '\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=')
|
||||
for regex in ModulesRegex: # 遍历正则模块列表
|
||||
if regex in enabled_modules_list:
|
||||
|
|
Reference in a new issue