diff --git a/components/Config.js b/components/Config.js index c5b675a..450cacb 100644 --- a/components/Config.js +++ b/components/Config.js @@ -109,6 +109,7 @@ class Config { * itemLength: number, * steamAvatar: boolean, * infoMode: number, + * log: boolean * }} */ get other () { diff --git a/config/default_config/other.yaml b/config/default_config/other.yaml index 1ca3345..b2ce2bc 100644 --- a/config/default_config/other.yaml +++ b/config/default_config/other.yaml @@ -15,3 +15,6 @@ steamAvatar: true # 1: 文字 # 2: 图片 (若图片发送时间长可更换为文字模式) infoMode: 2 + +# 是否开启日志 +log: true diff --git a/lib/logger.js b/lib/logger.js index 1a66974..28e038c 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -1,4 +1,4 @@ -import { Version } from '#components' +import { Config, Version } from '#components' import chalk from 'chalk' const logger = await (async () => { @@ -17,6 +17,8 @@ const getRandomHexColor = () => { export default { ...logger, - info: (...logs) => logger.info(chalk.hex(getRandomHexColor())(`[${Version.pluginName}]`, ...logs)), + info: (...logs) => Config.other.log + ? logger.info(chalk.hex(getRandomHexColor())(`[${Version.pluginName}]`, ...logs)) + : null, error: (...logs) => logger.error(`[${Version.pluginName}]`, ...logs) } diff --git a/models/setting/index.js b/models/setting/index.js index 9825e29..8ac5b97 100644 --- a/models/setting/index.js +++ b/models/setting/index.js @@ -197,6 +197,13 @@ export const cfgSchema = { } }, desc: 'steam状态发送消息的模式 1: 文字 2: 图片 若图片发送时间长可更换为文字' + }, + log: { + title: '日志输出', + key: '日志', + type: 'boolean', + def: true, + desc: '是否输出日志' } } },