entitysytem的logger返回类型更改,需要重写实现getLoggerName
This commit is contained in:
@@ -51,7 +51,7 @@ export abstract class EntitySystem implements ISystemBase {
|
||||
private _matcher: Matcher;
|
||||
private _eventListeners: EventListenerRecord[];
|
||||
private _scene: Scene | null;
|
||||
protected logger = createLogger('EntitySystem');
|
||||
protected logger: ReturnType<typeof createLogger>;
|
||||
|
||||
|
||||
/**
|
||||
@@ -136,6 +136,9 @@ export abstract class EntitySystem implements ISystemBase {
|
||||
this._entityIdMapVersion = -1;
|
||||
this._entityIdMapSize = 0;
|
||||
|
||||
// 初始化logger
|
||||
this.logger = createLogger(this.getLoggerName());
|
||||
|
||||
|
||||
this._entityCache = {
|
||||
frame: null,
|
||||
@@ -773,6 +776,14 @@ export abstract class EntitySystem implements ISystemBase {
|
||||
this.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Logger名称
|
||||
* 子类可以重写此方法来自定义logger名称
|
||||
*/
|
||||
protected getLoggerName(): string {
|
||||
return 'EntitySystem';
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户销毁回调
|
||||
*
|
||||
|
||||
@@ -199,8 +199,6 @@ export abstract class WorkerEntitySystem<TEntityData = any> extends EntitySystem
|
||||
constructor(matcher?: Matcher, config: WorkerSystemConfig = {}) {
|
||||
super(matcher);
|
||||
|
||||
this.logger = createLogger('WorkerEntitySystem');
|
||||
|
||||
// 验证和调整 worker 数量,确保不超过系统最大值
|
||||
const requestedWorkerCount = config.workerCount ?? this.getMaxSystemWorkerCount();
|
||||
const maxSystemWorkerCount = this.getMaxSystemWorkerCount();
|
||||
@@ -827,6 +825,10 @@ export abstract class WorkerEntitySystem<TEntityData = any> extends EntitySystem
|
||||
this.workerPool = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected override getLoggerName(): string {
|
||||
return 'WorkerEntitySystem';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user