mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-06-09 00:38:00 +08:00
fix: logger
This commit is contained in:
parent
6a7b58cb5e
commit
12c289d06a
@ -1,3 +1,4 @@
|
|||||||
|
import { debounce } from 'lodash-es';
|
||||||
import logInfo from './logger.json';
|
import logInfo from './logger.json';
|
||||||
|
|
||||||
export const enum LogLevel {
|
export const enum LogLevel {
|
||||||
@ -20,28 +21,28 @@ interface LoggerCatchReturns<T> {
|
|||||||
info: LoggerCatchInfo[];
|
info: LoggerCatchInfo[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// let logTip: HTMLSpanElement;
|
let logTip: HTMLSpanElement;
|
||||||
// if (!main.replayChecking) {
|
if (!main.replayChecking) {
|
||||||
// const tip = document.createElement('span');
|
const tip = document.createElement('span');
|
||||||
// logTip = tip;
|
logTip = tip;
|
||||||
// tip.style.position = 'fixed';
|
tip.style.position = 'fixed';
|
||||||
// tip.style.right = '0';
|
tip.style.right = '0';
|
||||||
// tip.style.bottom = '0';
|
tip.style.bottom = '0';
|
||||||
// tip.style.height = '20px';
|
tip.style.height = '20px';
|
||||||
// tip.style.width = 'auto';
|
tip.style.width = 'auto';
|
||||||
// tip.style.textAlign = 'right';
|
tip.style.textAlign = 'right';
|
||||||
// tip.style.padding = '0 5px';
|
tip.style.padding = '0 5px';
|
||||||
// tip.style.fontSize = '16px';
|
tip.style.fontSize = '16px';
|
||||||
// tip.style.fontFamily = 'Arial';
|
tip.style.fontFamily = 'Arial';
|
||||||
// tip.style.display = 'none';
|
tip.style.display = 'none';
|
||||||
// tip.style.margin = '2px';
|
tip.style.margin = '2px';
|
||||||
// document.body.appendChild(tip);
|
document.body.appendChild(tip);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// const hideTipText = debounce(() => {
|
const hideTipText = debounce(() => {
|
||||||
// if (main.replayChecking) return;
|
if (main.replayChecking) return;
|
||||||
// logTip.style.display = 'none';
|
logTip.style.display = 'none';
|
||||||
// }, 5000);
|
}, 5000);
|
||||||
|
|
||||||
const nums = new Set('1234567890');
|
const nums = new Set('1234567890');
|
||||||
|
|
||||||
@ -107,7 +108,8 @@ export class Logger {
|
|||||||
logger.error(16, 'error', code.toString());
|
logger.error(16, 'error', code.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const text = this.parseInfo(info[code], ...params);
|
|
||||||
|
const text = this.parseInfo(info, ...params);
|
||||||
if (this.catching) {
|
if (this.catching) {
|
||||||
this.catchedInfo.push({
|
this.catchedInfo.push({
|
||||||
level: LogLevel.ERROR,
|
level: LogLevel.ERROR,
|
||||||
@ -116,15 +118,15 @@ export class Logger {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (this.level <= LogLevel.ERROR && this.enabled) {
|
if (this.level <= LogLevel.ERROR && this.enabled) {
|
||||||
// if (!main.replayChecking) {
|
if (!main.replayChecking) {
|
||||||
// logTip.style.color = 'lightcoral';
|
logTip.style.color = 'lightcoral';
|
||||||
// logTip.style.display = 'block';
|
logTip.style.display = 'block';
|
||||||
// logTip.textContent = `Error thrown, please check in console.`;
|
logTip.textContent = `Error thrown, please check in console.`;
|
||||||
// hideTipText();
|
hideTipText();
|
||||||
// }
|
}
|
||||||
const n = Math.floor(code / 50) + 1;
|
const n = Math.floor(code / 50) + 1;
|
||||||
const n2 = code % 50;
|
const n2 = code % 50;
|
||||||
const url = `/_docs/logger/error/error${n}.html#error-code-${n2}`;
|
const url = `${location.origin}/_docs/logger/error/error${n}.html#error-code-${n2}`;
|
||||||
console.error(`[ERROR Code ${code}] ${text}. See ${url}`);
|
console.error(`[ERROR Code ${code}] ${text}. See ${url}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,7 +142,8 @@ export class Logger {
|
|||||||
logger.error(16, 'warn', code.toString());
|
logger.error(16, 'warn', code.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const text = this.parseInfo(info[code], ...params);
|
const text = this.parseInfo(info, ...params);
|
||||||
|
|
||||||
if (this.catching) {
|
if (this.catching) {
|
||||||
this.catchedInfo.push({
|
this.catchedInfo.push({
|
||||||
level: LogLevel.ERROR,
|
level: LogLevel.ERROR,
|
||||||
@ -149,15 +152,15 @@ export class Logger {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (this.level <= LogLevel.WARNING && this.enabled) {
|
if (this.level <= LogLevel.WARNING && this.enabled) {
|
||||||
// if (!main.replayChecking) {
|
if (!main.replayChecking) {
|
||||||
// logTip.style.color = 'gold';
|
logTip.style.color = 'gold';
|
||||||
// logTip.style.display = 'block';
|
logTip.style.display = 'block';
|
||||||
// logTip.textContent = `Warning thrown, please check in console.`;
|
logTip.textContent = `Warning thrown, please check in console.`;
|
||||||
// hideTipText();
|
hideTipText();
|
||||||
// }
|
}
|
||||||
const n = Math.floor(code / 50) + 1;
|
const n = Math.floor(code / 50) + 1;
|
||||||
const n2 = code % 50;
|
const n2 = code % 50;
|
||||||
const url = `/_docs/logger/warn/warn${n}.html#warn-code-${n2}`;
|
const url = `${location.origin}/_docs/logger/warn/warn${n}.html#warn-code-${n2}`;
|
||||||
console.warn(`[WARNING Code ${code}] ${text}. See ${url}`);
|
console.warn(`[WARNING Code ${code}] ${text}. See ${url}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user