diff --git a/browser-interface/packages/config/index.ts b/browser-interface/packages/config/index.ts index ae249494d6..6c24b16446 100644 --- a/browser-interface/packages/config/index.ts +++ b/browser-interface/packages/config/index.ts @@ -3,6 +3,7 @@ import { getFeatureFlagEnabled } from 'shared/meta/selectors' import { now } from 'lib/javascript/now' import { isURL } from 'lib/javascript/isURL' import { store } from 'shared/store/isolatedStore' +import logWrapper from '../lib/logger/wrap' /** * Estimated avatar height @@ -11,6 +12,9 @@ export const playerHeight = 1.6 // Entry points export const PREVIEW: boolean = !!(globalThis as any).preview +// update logger +logWrapper() + export const WORLD_EXPLORER = !PREVIEW export const RENDERER_WS = location.search.includes('ws') @@ -54,7 +58,7 @@ export const DEBUG_ANALYTICS = location.search.includes('DEBUG_ANALYTICS') export const DEBUG_REDUX = location.search.includes('DEBUG_REDUX') export const DEBUG_REDUX_SAGAS = location.search.includes('DEBUG_REDUX_SAGAS') export const DEBUG_SCENE_LOG = DEBUG || location.search.includes('DEBUG_SCENE_LOG') -export const DEBUG_KERNEL_LOG = !PREVIEW || location.search.includes('DEBUG_KERNEL_LOG') +export const DEBUG_KERNEL_LOG = location.search.includes('DEBUG_KERNEL_LOG') export const DEBUG_WS_MESSAGES = location.search.includes('DEBUG_WS_MESSAGES') export const DEBUG_VOICE_CHAT = location.search.includes('DEBUG_VOICE_CHAT') export const DEBUG_LOGS = location.search.includes('DEBUG_LOGS') diff --git a/browser-interface/packages/lib/logger/wrap.ts b/browser-interface/packages/lib/logger/wrap.ts index cfd699a3bc..a2b10742c6 100644 --- a/browser-interface/packages/lib/logger/wrap.ts +++ b/browser-interface/packages/lib/logger/wrap.ts @@ -1,4 +1,6 @@ -export const METHODS = ['info', 'log', 'warn', 'trace'] as const +import { PREVIEW } from "../../config" + +export const METHODS = ['info', 'log', 'warn', 'trace', 'error'] as const type Method = (typeof METHODS)[number] /** @@ -7,8 +9,15 @@ type Method = (typeof METHODS)[number] */ export const _console = Object.assign({}, console) +function getPrefix(value?: string) { + if (value) return value + if (location.search.includes('DEBUG_LOGS')) return '*' + if (PREVIEW) return 'kernel:scene' + return 'kernel:scene' +} + export function wrap(testPrefix?: string) { - const prefix = testPrefix ? testPrefix : location.search.includes('DEBUG_LOGS') ? '*' : 'kernel' + const prefix = getPrefix(testPrefix) function logger(method: Method) { return function log(...args: any[]): void { const [logPrefix] = args