/**
* @module Log
* @description Lightweight styled console logging utility.
* Drop-in replacement for the log function currently in constants.js.
*
* Usage:
* import log from './log';
*
* log('Hello'); // plain message
* log('Initialized.', 'initUI'); // scoped message
* log.warn('Slow frame', 'Renderer'); // severity shorthand
* log.error('GL context lost', 'WebGL');
* log.debug('Pan delta', 'Mouse');
*/
import {CONSOLE_GROUP_STYLE, CONSOLE_MESSAGE_STYLE} from "./constants";
/** @enum {string} */
export const LOG_LEVEL = {
LOG: 'log',
DEBUG: 'debug',
WARN: 'warn',
ERROR: 'error'
}
/**
* Logs a styled message to the console.
* @param {string} message - The message to log.
* @param {string} [scope=''] - Optional scope/context label shown in brackets.
* @param {string} [severity=LOG_LEVEL.LOG] - Severity level from LOG_LEVEL.
*/
const log = (message, scope = '', severity = LOG_LEVEL.LOG) => {
const prefix = scope ? `%c[${scope}]%c ` : '%c%c';
console[severity](prefix + message, CONSOLE_GROUP_STYLE, CONSOLE_MESSAGE_STYLE);
}
/** @param {string} message @param {string} [scope] */
log.debug = (message, scope) => log(message, scope, LOG_LEVEL.DEBUG);
/** @param {string} message @param {string} [scope] */
log.warn = (message, scope) => log(message, scope, LOG_LEVEL.WARN);
/** @param {string} message @param {string} [scope] */
log.error = (message, scope) => log(message, scope, LOG_LEVEL.ERROR);
export {log};
export default log;