feat(log): 优化日志打印
All checks were successful
Egg Server MIflow / build-image (push) Successful in 41s

This commit is contained in:
zhaoyingbo 2024-08-22 02:01:15 +00:00
parent 8af3d6c118
commit d283540b00
2 changed files with 10 additions and 7 deletions

View File

@ -12,15 +12,19 @@ initSchedule()
const server = Bun.serve({
async fetch(req) {
// 路由处理
const { exactCheck, startsWithCheck, fullCheck } = makeCheckPathTool(
req.url
)
// 生成上下文
const ctx = await genContext(req)
// 非健康检查由打印必要信息
if (!fullCheck("/health")) {
ctx.logger.info(`${req.method} ${req.url}`)
logger.debug(`req body: ${ctx.text}`)
}
// 逻辑处理
try {
// 路由处理
const { exactCheck, startsWithCheck, fullCheck } = makeCheckPathTool(
req.url
)
// 非健康检查由打印
if (!fullCheck("/health")) ctx.logger.info(`${req.method} ${req.url}`)
// 机器人
if (exactCheck("/bot")) return await manageBotReq(ctx)
// 消息代理发送

View File

@ -26,7 +26,6 @@ const genContext = async (req: Request) => {
} catch {
/* empty */
}
logger.debug(`req body: ${text}`)
return {
req,
requestId,