chore(lib/utils): remove logger
This commit is contained in:
parent
c8567e1a7c
commit
6594fc6fa1
5 changed files with 14 additions and 54 deletions
|
|
@ -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<T = any>(
|
|||
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,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,6 @@
|
|||
"./generators": {
|
||||
"default": "./src/generators.ts"
|
||||
},
|
||||
"./logger": {
|
||||
"default": "./src/logger.ts"
|
||||
},
|
||||
"./objects": {
|
||||
"default": "./src/objects.ts"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
*/
|
||||
|
||||
import { getCurrentStack } from './errors'
|
||||
import { createLogger } from './logger'
|
||||
|
||||
const _targets = new WeakMap<object, object>()
|
||||
|
||||
|
|
@ -254,10 +253,9 @@ export function destructure<T extends object>(
|
|||
})
|
||||
}
|
||||
|
||||
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,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue