- 新增 Logger 类提供统一的日志和警告输出,支持全局和模块级开关 - 重构 SkillView、HeroViewComp 和 HeroAtkSystem 中的调试日志方法,改用 Logger 类 - 在 HeroViewComp 中添加调试模式属性便于编辑器配置 - 统一日志格式为 [标签] + 内容,提高日志可读性和维护性
29 lines
854 B
TypeScript
29 lines
854 B
TypeScript
export class Logger {
|
|
/** 总开关:控制所有日志输出 */
|
|
public static GLOBAL_ENABLED: boolean = true;
|
|
|
|
/**
|
|
* 统一日志输出
|
|
* @param enable 单独开关(模块级开关)
|
|
* @param tag 标签(通常是类名或模块名)
|
|
* @param args 日志内容
|
|
*/
|
|
public static log(enable: boolean, tag: string, ...args: any[]) {
|
|
if (this.GLOBAL_ENABLED && enable) {
|
|
console.log(`[${tag}]`, ...args);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 统一警告输出
|
|
* @param enable 单独开关(模块级开关)
|
|
* @param tag 标签(通常是类名或模块名)
|
|
* @param args 警告内容
|
|
*/
|
|
public static warn(enable: boolean, tag: string, ...args: any[]) {
|
|
if (this.GLOBAL_ENABLED && enable) {
|
|
console.warn(`[${tag}]`, ...args);
|
|
}
|
|
}
|
|
}
|