Skip to main content

Logger

The Logger class provides a simple and flexible logging mechanism with multiple log levels.

static enable(): void

Enables the logger, allowing messages to be logged. By default, the logger is enabled.

Example:

Logger.enable();

static disable(): void

Disables the logger, preventing any log messages from being processed. This affects all the scripting runtime, so logs will also be disabled when running in editor mode. For final production builds, use disable in combination with a preprocessor directive (e.g., DEBUG) to ensure logs are turned off only in production.

Best Practice Example:

#ifdef DEBUG
Logger.enable();
#else
Logger.disable(); // Disable logs for production
#endif

static log(...data: any): void

Logs general information using the LOG log level.

Example:

Logger.log('This is a general log message');

static info(...data: any): void

Logs informational messages using the INFO log level.

Example:

Logger.info('This is an info message');

static warn(...data: any): void

Logs warnings using the WARN log level.

Example:

Logger.warn('This is a warning');

static error(...data: any): void

Logs error messages using the ERROR log level.

Example:

Logger.error('This is an error message');