Skip to content

Commit

Permalink
perf: 可开关日志输出
Browse files Browse the repository at this point in the history
  • Loading branch information
XasYer committed Dec 2, 2024
1 parent 348d08a commit 492d498
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions components/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class Config {
* itemLength: number,
* steamAvatar: boolean,
* infoMode: number,
* log: boolean
* }}
*/
get other () {
Expand Down
3 changes: 3 additions & 0 deletions config/default_config/other.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ steamAvatar: true
# 1: 文字
# 2: 图片 (若图片发送时间长可更换为文字模式)
infoMode: 2

# 是否开启日志
log: true
6 changes: 4 additions & 2 deletions lib/logger.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Version } from '#components'
import { Config, Version } from '#components'
import chalk from 'chalk'

const logger = await (async () => {
Expand All @@ -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)
}
7 changes: 7 additions & 0 deletions models/setting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@ export const cfgSchema = {
}
},
desc: 'steam状态发送消息的模式 1: 文字 2: 图片 若图片发送时间长可更换为文字'
},
log: {
title: '日志输出',
key: '日志',
type: 'boolean',
def: true,
desc: '是否输出日志'
}
}
},
Expand Down

0 comments on commit 492d498

Please sign in to comment.