Skip to content

Commit bcf87a9

Browse files
committed
feat: 新增日志等级Notice (#454)
Fixed #454
1 parent 737feae commit bcf87a9

4 files changed

Lines changed: 24 additions & 12 deletions

File tree

env.example.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = Object.freeze({
1212
* - `ENABLE_MULTIPLE_ACCOUNT` 是否启用多账号
1313
* - `MULTIPLE_ACCOUNT_PARM` 多账号参数(JSON格式) <不推荐使用
1414
* ## 调试相关
15-
* - `LOTTERY_LOG_LEVEL` 输出日志等级 Error<Warn<Info<Debug 1<2<3<4
15+
* - `LOTTERY_LOG_LEVEL` 输出日志等级 Error<Warn<Notice<Info<Debug 0<1<2<3<4
1616
* - `NOT_GO_LOTTERY` 关闭抽奖行为
1717
*
1818
* ## 多账号

lib/check.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ async function isMe(num) {
9292
log.info('中奖检测', '--> OK');
9393
}
9494
if (desp) {
95-
log.info('可能中奖了', desp);
95+
log.notice('可能中奖了', desp);
9696
await sendNotify(`帐号${num}可能中奖了`, desp);
9797
} else {
98-
log.info('中奖检测', '暂未中奖');
98+
log.notice('中奖检测', '暂未中奖');
9999
}
100100
return;
101101
}

lib/update.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ async function update(isDdownload) {
8383
log.info('自动下载', '成功下载到当前目录');
8484
log.info('检查更新', '请手动解压替换可执行文件');
8585
}
86-
log.info('更新说明', '\n' + text + '\n');
86+
log.notice('更新说明', '\n' + text + '\n');
8787
} else {
8888
throw `未找到能在此平台(${process.platform})-(${process.arch})上运行的版本,建议以源码运行`;
8989
}

lib/utils.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ const utils = {
191191
_level: 3,
192192
_colors: [
193193
chalk.hex('#64B3FF'), chalk.grey, chalk.hex('#FFA500'),
194-
chalk.hex('#0070BB'), chalk.hex('#48BB31'), chalk.hex('#BBBB23'), chalk.hex('#FF0006')
194+
chalk.hex('#0070BB'), chalk.hex('#48BB31'), chalk.hex('#BFFF00'), chalk.hex('#BBBB23'), chalk.hex('#FF0006')
195195
],
196196
_iso_time: () => new Date(Date.now() + 288e5).toISOString().slice(0, -1) + '+08',
197197
_cache: [],
@@ -231,7 +231,7 @@ const utils = {
231231
process.stdout.write(status_bar);
232232
},
233233
debug(context, msg) {
234-
if (this._level > 3) {
234+
if (this._level >= 4) {
235235
if (msg instanceof Object) msg = JSON.stringify(msg, null, 4);
236236
let color_text_pair = [
237237
[this._colors[0], `[${this._iso_time()}]`],
@@ -243,7 +243,7 @@ const utils = {
243243
}
244244
},
245245
info(context, msg) {
246-
if (this._level > 2) {
246+
if (this._level >= 3) {
247247
let color_text_pair = [
248248
[this._colors[0], `[${this._iso_time()}]`],
249249
[this._colors[1], '[Info]'],
@@ -254,25 +254,37 @@ const utils = {
254254
this.proPrint(color_text_pair.map(([color, text]) => color(text)));
255255
}
256256
},
257+
notice(context, msg) {
258+
if (this._level >= 2) {
259+
let color_text_pair = [
260+
[this._colors[0], `[${this._iso_time()}]`],
261+
[this._colors[1], '[Notice]'],
262+
[this._colors[2], `[帐号${process.env['NUMBER']} ${context}]`],
263+
[this._colors[5], `[${msg}]`],
264+
];
265+
this._cache.push(color_text_pair.map(it => it[1]).join(' '));
266+
this.proPrint(color_text_pair.map(([color, text]) => color(text)));
267+
}
268+
},
257269
warn(context, msg) {
258-
if (this._level > 1) {
270+
if (this._level >= 1) {
259271
let color_text_pair = [
260272
[this._colors[0], `[${this._iso_time()}]`],
261273
[this._colors[1], '[Warn]'],
262274
[this._colors[2], `[帐号${process.env['NUMBER']} ${context}]`],
263-
[this._colors[5], `[\n${msg}\n]`],
275+
[this._colors[6], `[\n${msg}\n]`],
264276
];
265277
this._cache.push(color_text_pair.map(it => it[1]).join(' '));
266278
this.proPrint(color_text_pair.map(([color, text]) => color(text)));
267279
}
268280
},
269281
error(context, msg) {
270-
if (this._level > 0) {
282+
if (this._level >= 0) {
271283
let color_text_pair = [
272284
[this._colors[0], `[${this._iso_time()}]`],
273285
[this._colors[1], '[Error]'],
274286
[this._colors[2], `[帐号${process.env['NUMBER']} ${context}]`],
275-
[this._colors[6], `[\n${msg}\n]`],
287+
[this._colors[7], `[\n${msg}\n]`],
276288
];
277289
this._cache.push(color_text_pair.map(it => it[1]).join(' '));
278290
this.proPrint(color_text_pair.map(([color, text]) => color(text)));
@@ -475,7 +487,7 @@ const utils = {
475487
});
476488
});
477489
},
478-
getIpInfo() {
490+
getIpInfo() {
479491
return new Promise((resolve) => {
480492
send({
481493
url: 'https://myip.qq.com/',

0 commit comments

Comments
 (0)