Refactor BxLogger

This commit is contained in:
redphx 2024-10-13 16:06:01 +07:00
parent e4d73f9e36
commit 4f7b23912d
3 changed files with 15 additions and 39 deletions

View File

@ -12,18 +12,11 @@
// ==/UserScript==
"use strict";
class BxLogger {
static #PREFIX = "[BxC]";
static info(tag, ...args) {
BxLogger.#log("#008746", tag, ...args);
}
static warning(tag, ...args) {
BxLogger.#log("#c1a404", tag, ...args);
}
static error(tag, ...args) {
BxLogger.#log("#c10404", tag, ...args);
}
static #log(color, tag, ...args) {
console.log(`%c${BxLogger.#PREFIX}`, `color:${color};font-weight:bold;`, tag, "//", ...args);
static info = (tag, ...args) => BxLogger.log("#008746", tag, ...args);
static warning = (tag, ...args) => BxLogger.log("#c1a404", tag, ...args);
static error = (tag, ...args) => BxLogger.log("#c10404", tag, ...args);
static log(color, tag, ...args) {
console.log("%c[BxC]", `color:${color};font-weight:bold;`, tag, "//", ...args);
}
}
window.BxLogger = BxLogger;

View File

@ -14,18 +14,11 @@
// ==/UserScript==
"use strict";
class BxLogger {
static #PREFIX = "[BxC]";
static info(tag, ...args) {
BxLogger.#log("#008746", tag, ...args);
}
static warning(tag, ...args) {
BxLogger.#log("#c1a404", tag, ...args);
}
static error(tag, ...args) {
BxLogger.#log("#c10404", tag, ...args);
}
static #log(color, tag, ...args) {
console.log(`%c${BxLogger.#PREFIX}`, `color:${color};font-weight:bold;`, tag, "//", ...args);
static info = (tag, ...args) => BxLogger.log("#008746", tag, ...args);
static warning = (tag, ...args) => BxLogger.log("#c1a404", tag, ...args);
static error = (tag, ...args) => BxLogger.log("#c10404", tag, ...args);
static log(color, tag, ...args) {
console.log("%c[BxC]", `color:${color};font-weight:bold;`, tag, "//", ...args);
}
}
window.BxLogger = BxLogger;

View File

@ -5,22 +5,12 @@ const enum TextColor {
}
export class BxLogger {
static #PREFIX = '[BxC]';
static info = (tag: string, ...args: any[]) => BxLogger.log(TextColor.INFO, tag, ...args);
static warning = (tag: string, ...args: any[]) => BxLogger.log(TextColor.WARNING, tag, ...args);
static error = (tag: string, ...args: any[]) => BxLogger.log(TextColor.ERROR, tag, ...args);
static info(tag: string, ...args: any[]) {
BxLogger.#log(TextColor.INFO, tag, ...args);
}
static warning(tag: string, ...args: any[]) {
BxLogger.#log(TextColor.WARNING, tag, ...args);
}
static error(tag: string, ...args: any[]) {
BxLogger.#log(TextColor.ERROR, tag, ...args);
}
static #log(color: string, tag: string, ...args: any) {
console.log(`%c${BxLogger.#PREFIX}`, `color:${color};font-weight:bold;`, tag, '//', ...args);
private static log(color: string, tag: string, ...args: any) {
console.log(`%c[BxC]`, `color:${color};font-weight:bold;`, tag, '//', ...args);
}
}