代码提交

This commit is contained in:
2025-07-18 09:32:46 +08:00
parent d6383ac74d
commit 515fb83408
4 changed files with 33 additions and 20 deletions

View File

@@ -269,11 +269,11 @@ class LogMonitorAdaptive {
}
/* ------------------------ 日志渲染 ------------------------ */
log(message, level = 'info') {
log(message, level = 'info', ts = this.formatTime(new Date())) {
if (!this.cfg.levels.includes(level)) level = 'info';
if (this.isPaused) return;
const ts = this.cfg.showTimestamp ? this.formatTime(new Date()) : '';
ts = this.cfg.showTimestamp ? ts : '';
this.logs.push({message, level, ts, id: Date.now() + Math.random()});
if (this.logs.length > this.cfg.maxLines) this.logs.shift();
@@ -433,27 +433,27 @@ class LogMonitorAdaptive {
}
/* 快捷方法 */
info(msg) {
this.log(msg, 'info');
info(msg, ts = this.formatTime(new Date())) {
this.log(msg, 'info', ts);
}
warn(msg) {
this.log(msg, 'warn');
warn(msg, ts = this.formatTime(new Date())) {
this.log(msg, 'warn', ts);
}
error(msg) {
this.log(msg, 'error');
error(msg, ts = this.formatTime(new Date())) {
this.log(msg, 'error', ts);
}
success(msg) {
this.log(msg, 'success');
success(msg, ts = this.formatTime(new Date())) {
this.log(msg, 'success', ts);
}
debug(msg) {
this.log(msg, 'debug');
debug(msg, ts = this.formatTime(new Date())) {
this.log(msg, 'debug', ts);
}
system(msg) {
this.log(msg, 'system');
system(msg, ts = this.formatTime(new Date())) {
this.log(msg, 'system', ts);
}
}