Skip to content

Commit 0dfbab3

Browse files
committed
feat: 添加更新日志等级的命令
1 parent caa5b3b commit 0dfbab3

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/apps/logger.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,3 +365,14 @@ export const errorLogViewer = karin.command(/^#错误日志\s*(\d+)?$/, async (e
365365
return false
366366
}
367367
}, { name: '错误日志查看器', perm: 'admin' })
368+
369+
export const updateLogger = karin.command(/^#\s*('trace'|'debug'|'info'|'warn'|'error'|'fatal')$/i, async (e) => {
370+
const match = e.msg.match(/^#\s*('trace'|'debug'|'info'|'warn'|'error'|'fatal')$/i)?.[1].toLowerCase()
371+
if (!match) {
372+
await e.reply('无效的日志等级')
373+
return false
374+
}
375+
logger.level = match
376+
await e.reply(`已将日志等级更新为 ${match.toUpperCase()}`)
377+
return true
378+
}, { name: '更新日志等级', perm: 'admin' })

0 commit comments

Comments
 (0)