chantey
chantey

Reputation: 5837

BabylonJS - Suppress engine start logs

I'm running some tests using Babylonjs and the following message gets printed to the console for each test:

#null engine:
BJS - [09:12:32]: Babylon.js v4.2.1 - Null engine

#thin engine:
Babylon.js v4.2.1 - WebGL2 - Parallel shader compilation

Its a bit noisy, is there a way to turn this off?

Upvotes: 0

Views: 343

Answers (1)

chantey
chantey

Reputation: 5837

The null engine logs can be disabled by using the Logger object. Just be sure to set the log level before creating your engine.

import { NullEngine, Logger } from '@babylonjs/core'

Logger.LogLevels = Logger.WarningLogLevel
const engine = new NullEngine()

Note that this does not suppress the regular engine startup message as that uses console.log instead of the Logger object, source here. For that case we will need to override log for a moment:


import { Engine } from '@babylonjs/core'


const logFunc = console.log
console.log = ()=>{}
const engine = new Engine()
console.log = logFunc

Upvotes: 3

Related Questions