mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
tidy(ui): consolidate getLoggingContext builders
This commit is contained in:
parent
8e1a70b008
commit
ad9312e989
@ -30,7 +30,7 @@ export class CanvasBrushLine {
|
||||
this.parent = parent;
|
||||
this.manager = parent.manager;
|
||||
|
||||
this.getLoggingContext = this.manager.buildObjectGetLoggingContext(this);
|
||||
this.getLoggingContext = this.manager.buildGetLoggingContext(this);
|
||||
this.log = this.manager.buildLogger(this.getLoggingContext);
|
||||
|
||||
this.log.trace({ state }, 'Creating brush line');
|
||||
|
@ -29,7 +29,7 @@ export class CanvasEraserLine {
|
||||
this.id = id;
|
||||
this.parent = parent;
|
||||
this.manager = parent.manager;
|
||||
this.getLoggingContext = this.manager.buildObjectGetLoggingContext(this);
|
||||
this.getLoggingContext = this.manager.buildGetLoggingContext(this);
|
||||
this.log = this.manager.buildLogger(this.getLoggingContext);
|
||||
|
||||
this.log.trace({ state }, 'Creating eraser line');
|
||||
|
@ -39,7 +39,7 @@ export class CanvasImage {
|
||||
this.id = id;
|
||||
this.parent = parent;
|
||||
this.manager = parent.manager;
|
||||
this.getLoggingContext = this.manager.buildObjectGetLoggingContext(this);
|
||||
this.getLoggingContext = this.manager.buildGetLoggingContext(this);
|
||||
this.log = this.manager.buildLogger(this.getLoggingContext);
|
||||
|
||||
this.log.trace({ state }, 'Creating image');
|
||||
|
@ -60,7 +60,7 @@ export class CanvasLayer {
|
||||
constructor(state: LayerEntity, manager: CanvasManager) {
|
||||
this.id = state.id;
|
||||
this.manager = manager;
|
||||
this.getLoggingContext = this.manager.buildEntityGetLoggingContext(this);
|
||||
this.getLoggingContext = this.manager.buildGetLoggingContext(this);
|
||||
this.log = this.manager.buildLogger(this.getLoggingContext);
|
||||
this.log.debug({ state }, 'Creating layer');
|
||||
|
||||
|
@ -591,26 +591,33 @@ export class CanvasManager {
|
||||
});
|
||||
}
|
||||
|
||||
buildObjectGetLoggingContext = (
|
||||
instance: CanvasBrushLine | CanvasEraserLine | CanvasRect | CanvasImage | CanvasTransformer
|
||||
buildGetLoggingContext = (
|
||||
instance:
|
||||
| CanvasBrushLine
|
||||
| CanvasEraserLine
|
||||
| CanvasRect
|
||||
| CanvasImage
|
||||
| CanvasTransformer
|
||||
| CanvasLayer
|
||||
| CanvasStagingArea
|
||||
): GetLoggingContext => {
|
||||
return (extra?: JSONObject): JSONObject => {
|
||||
return {
|
||||
...instance.parent.getLoggingContext(),
|
||||
objectId: instance.id,
|
||||
...extra,
|
||||
if (instance instanceof CanvasLayer || instance instanceof CanvasStagingArea) {
|
||||
return (extra?: JSONObject): JSONObject => {
|
||||
return {
|
||||
...instance.manager.getLoggingContext(),
|
||||
entityId: instance.id,
|
||||
...extra,
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
buildEntityGetLoggingContext = (instance: CanvasLayer | CanvasStagingArea): GetLoggingContext => {
|
||||
return (extra?: JSONObject): JSONObject => {
|
||||
return {
|
||||
...instance.manager.getLoggingContext(),
|
||||
entityId: instance.id,
|
||||
...extra,
|
||||
} else {
|
||||
return (extra?: JSONObject): JSONObject => {
|
||||
return {
|
||||
...instance.parent.getLoggingContext(),
|
||||
objectId: instance.id,
|
||||
...extra,
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
logDebugInfo() {
|
||||
|
@ -28,7 +28,7 @@ export class CanvasRect {
|
||||
this.id = id;
|
||||
this.parent = parent;
|
||||
this.manager = parent.manager;
|
||||
this.getLoggingContext = this.manager.buildObjectGetLoggingContext(this);
|
||||
this.getLoggingContext = this.manager.buildGetLoggingContext(this);
|
||||
this.log = this.manager.buildLogger(this.getLoggingContext);
|
||||
this.log.trace({ state }, 'Creating rect');
|
||||
|
||||
|
@ -22,7 +22,7 @@ export class CanvasStagingArea {
|
||||
constructor(manager: CanvasManager) {
|
||||
this.id = getPrefixedId(CanvasStagingArea.TYPE);
|
||||
this.manager = manager;
|
||||
this.getLoggingContext = this.manager.buildEntityGetLoggingContext(this);
|
||||
this.getLoggingContext = this.manager.buildGetLoggingContext(this);
|
||||
this.log = this.manager.buildLogger(this.getLoggingContext);
|
||||
this.log.debug('Creating staging area');
|
||||
|
||||
|
@ -63,7 +63,7 @@ export class CanvasTransformer {
|
||||
this.manager = parent.manager;
|
||||
this.transformTarget = transformTarget;
|
||||
|
||||
this.getLoggingContext = this.manager.buildObjectGetLoggingContext(this);
|
||||
this.getLoggingContext = this.manager.buildGetLoggingContext(this);
|
||||
this.log = this.manager.buildLogger(this.getLoggingContext);
|
||||
this.subscriptions = [];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user