From 4f7b23912d27810e3f501fc9d1f20b650d884dd5 Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Sun, 13 Oct 2024 16:06:01 +0700 Subject: [PATCH] Refactor BxLogger --- dist/better-xcloud.lite.user.js | 17 +++++------------ dist/better-xcloud.user.js | 17 +++++------------ src/utils/bx-logger.ts | 20 +++++--------------- 3 files changed, 15 insertions(+), 39 deletions(-) diff --git a/dist/better-xcloud.lite.user.js b/dist/better-xcloud.lite.user.js index f907642..24c29b9 100644 --- a/dist/better-xcloud.lite.user.js +++ b/dist/better-xcloud.lite.user.js @@ -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; diff --git a/dist/better-xcloud.user.js b/dist/better-xcloud.user.js index 6f1b065..56adb21 100644 --- a/dist/better-xcloud.user.js +++ b/dist/better-xcloud.user.js @@ -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; diff --git a/src/utils/bx-logger.ts b/src/utils/bx-logger.ts index da0441c..c24f739 100644 --- a/src/utils/bx-logger.ts +++ b/src/utils/bx-logger.ts @@ -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); } }