feat: 引入集中式日志工具类并重构调试日志
- 新增 Logger 类提供统一的日志和警告输出,支持全局和模块级开关 - 重构 SkillView、HeroViewComp 和 HeroAtkSystem 中的调试日志方法,改用 Logger 类 - 在 HeroViewComp 中添加调试模式属性便于编辑器配置 - 统一日志格式为 [标签] + 内容,提高日志可读性和维护性
This commit is contained in:
28
assets/script/game/common/Logger.ts
Normal file
28
assets/script/game/common/Logger.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
9
assets/script/game/common/Logger.ts.meta
Normal file
9
assets/script/game/common/Logger.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "0d4013a0-024f-4b53-8c1c-d366a381b64d",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user