From 6594fc6fa156b0f7d57e0a0db1b5bcb0e01925d0 Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Sat, 14 Jun 2025 21:48:52 +0700 Subject: [PATCH] chore(lib/utils): remove `logger` --- lib/modules/src/finders/lookup.ts | 13 ++++++---- lib/utils/package.json | 3 --- lib/utils/src/logger.ts | 36 --------------------------- lib/utils/src/proxy.ts | 8 +++--- src/patches/log-promise-rejections.ts | 8 +++--- 5 files changed, 14 insertions(+), 54 deletions(-) delete mode 100644 lib/utils/src/logger.ts diff --git a/lib/modules/src/finders/lookup.ts b/lib/modules/src/finders/lookup.ts index 0d9f208..62cc235 100644 --- a/lib/modules/src/finders/lookup.ts +++ b/lib/modules/src/finders/lookup.ts @@ -1,5 +1,4 @@ import { getCurrentStack } from '@revenge-mod/utils/errors' -import { createLogger } from '@revenge-mod/utils/logger' import { _inits, _paths, _uninits } from '../metro/_internal' import { getInitializedModuleExports } from '../metro/utils' import { exportsFromFilterResultFlag, runFilter } from './_internal' @@ -210,15 +209,16 @@ export function lookupModuleByImportedPath( return [getInitializedModuleExports(id), id] } -const logger = createLogger('revenge.modules.finders.lookup') - /** * Warns the developer that the filter matched during exportsless comparison, but not during the full comparison. * This will cause modules to be initialized unnecessarily, and may cause issues. * @internal */ function warnDeveloperAboutPartialFilterMatch(id: Metro.ModuleID, key: string) { - logger.wtf(`${key} matched module ${id} partially.\n${getCurrentStack()}`) + nativeLoggingHook( + `\u001b[33m${key} matched module ${id} partially.\n${getCurrentStack()}\u001b[0m`, + 2, + ) } const __blacklistedFunctions = __BUILD_FLAG_DEBUG_MODULE_LOOKUPS @@ -239,5 +239,8 @@ async function warnDeveloperAboutNoFilterMatch(filter: Filter) { for (const func of __blacklistedFunctions) if (stack.includes((await func).name)) return - logger.wtf(`No module found for filter: ${filter.key}\n${stack}`) + nativeLoggingHook( + `\u001b[31mNo module found for filter: ${filter.key}\n${stack}\u001b[0m`, + 2, + ) } diff --git a/lib/utils/package.json b/lib/utils/package.json index 36eba3c..7557311 100644 --- a/lib/utils/package.json +++ b/lib/utils/package.json @@ -15,9 +15,6 @@ "./generators": { "default": "./src/generators.ts" }, - "./logger": { - "default": "./src/logger.ts" - }, "./objects": { "default": "./src/objects.ts" }, diff --git a/lib/utils/src/logger.ts b/lib/utils/src/logger.ts deleted file mode 100644 index fbfc30a..0000000 --- a/lib/utils/src/logger.ts +++ /dev/null @@ -1,36 +0,0 @@ -export function createLogger(tag: string) { - return { - log: (message: string) => console.log(`[${tag}] ${message}`), - warn: (message: string) => console.warn(`[${tag}] ${message}`), - error: (message: string) => console.error(`[${tag}] ${message}`), - wtf: (message: string) => - console.error(`\u001b[31m[${tag}] ${message}\u001b[0m`), - } satisfies BasicLogger -} - -export interface BasicLogger { - /** - * Log a message to the console. - */ - log(...args: unknown[]): void - /** - * Log a warning message to the console. - * - * On Android, this will print to logcat with the `WARN` level. - */ - warn(...args: unknown[]): void - /** - * Log an error message to the console. - * - * On Android, this will print to logcat with the `ERROR` level. - */ - error(...args: unknown[]): void - /** - * [*What a Terrible Failure!*](https://developer.android.com/reference/android/util/Log#wtf(java.lang.String,%20java.lang.String)) - * - * Log an error message to the console in red (ANSI) - * - * On Android, this will print to logcat with the `ERROR` level. - */ - wtf(...args: unknown[]): void -} diff --git a/lib/utils/src/proxy.ts b/lib/utils/src/proxy.ts index 84cb52f..270e647 100644 --- a/lib/utils/src/proxy.ts +++ b/lib/utils/src/proxy.ts @@ -4,7 +4,6 @@ */ import { getCurrentStack } from './errors' -import { createLogger } from './logger' const _targets = new WeakMap() @@ -254,10 +253,9 @@ export function destructure( }) } -const logger = createLogger('revenge.utils.proxy') - function warnDeveloperAboutNullishProxifiedValue() { - logger.wtf( - `Proxified value is nullish! The signal is may be invalid.\n${getCurrentStack()}`, + nativeLoggingHook( + `\u001b[33mProxified value is nullish! The signal is may be invalid.\n${getCurrentStack()}\u001b[0m`, + 3, ) } diff --git a/src/patches/log-promise-rejections.ts b/src/patches/log-promise-rejections.ts index 9bda10d..31a8b51 100644 --- a/src/patches/log-promise-rejections.ts +++ b/src/patches/log-promise-rejections.ts @@ -6,9 +6,6 @@ */ import { getErrorStack } from '@revenge-mod/utils/errors' -import { createLogger } from '@revenge-mod/utils/logger' - -const logger = createLogger('revenge.promise-rejections') const ErrorTypeWhitelist = [ReferenceError, TypeError, RangeError] @@ -17,8 +14,9 @@ Promise._m = (promise, err) => { setTimeout( () => promise._h === 0 && - logger.error( - `Unhandled promise rejection: ${getErrorStack(err)}`, + nativeLoggingHook( + `\u001b[33mUnhandled promise rejection: ${getErrorStack(err)}\u001b[0m`, + 2, ), ErrorTypeWhitelist.some(it => err instanceof it) ? 0 : 2000, // The time is completely arbitary. I've picked what Hermes chose.