Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove kernel & unity logs in preview #6141

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion browser-interface/packages/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand Down Expand Up @@ -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')
Expand Down
13 changes: 11 additions & 2 deletions browser-interface/packages/lib/logger/wrap.ts
Original file line number Diff line number Diff line change
@@ -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]

/**
Expand All @@ -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
Expand Down
Loading