import { _decorator} from 'cc'; import { Constants } from '../data/Constants'; const { ccclass, property } = _decorator; @ccclass('Logger') export class Logger{ /** * 调试日志(生产环境代码会被完全移除) * 使用示例: * Logger.debug('当前状态:', state); */ static log = Constants.isDebug ? (...args: any[]): void => { console.log('[DEBUG]', ...args); } : (): void => {}; // 生产环境空函数 /** * 调试日志(生产环境代码会被完全移除) * 使用示例: * Logger.debug('当前状态:', state); */ static error = Constants.isDebug ? (...args: any[]): void => { console.error('[DEBUG]', ...args); console.trace('调试堆栈'); } : (): void => {}; // 生产环境空函数 /** * 调试日志(生产环境代码会被完全移除) * 使用示例: * Logger.debug('当前状态:', state); */ static warn = Constants.isDebug ? (...args: any[]): void => { console.warn('[DEBUG]', ...args); } : (): void => {}; // 生产环境空函数 }