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.parent = parent;
|
||||||
this.manager = parent.manager;
|
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 = this.manager.buildLogger(this.getLoggingContext);
|
||||||
|
|
||||||
this.log.trace({ state }, 'Creating brush line');
|
this.log.trace({ state }, 'Creating brush line');
|
||||||
|
@ -29,7 +29,7 @@ export class CanvasEraserLine {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.manager = parent.manager;
|
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 = this.manager.buildLogger(this.getLoggingContext);
|
||||||
|
|
||||||
this.log.trace({ state }, 'Creating eraser line');
|
this.log.trace({ state }, 'Creating eraser line');
|
||||||
|
@ -39,7 +39,7 @@ export class CanvasImage {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.manager = parent.manager;
|
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 = this.manager.buildLogger(this.getLoggingContext);
|
||||||
|
|
||||||
this.log.trace({ state }, 'Creating image');
|
this.log.trace({ state }, 'Creating image');
|
||||||
|
@ -60,7 +60,7 @@ export class CanvasLayer {
|
|||||||
constructor(state: LayerEntity, manager: CanvasManager) {
|
constructor(state: LayerEntity, manager: CanvasManager) {
|
||||||
this.id = state.id;
|
this.id = state.id;
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
this.getLoggingContext = this.manager.buildEntityGetLoggingContext(this);
|
this.getLoggingContext = this.manager.buildGetLoggingContext(this);
|
||||||
this.log = this.manager.buildLogger(this.getLoggingContext);
|
this.log = this.manager.buildLogger(this.getLoggingContext);
|
||||||
this.log.debug({ state }, 'Creating layer');
|
this.log.debug({ state }, 'Creating layer');
|
||||||
|
|
||||||
|
@ -591,26 +591,33 @@ export class CanvasManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
buildObjectGetLoggingContext = (
|
buildGetLoggingContext = (
|
||||||
instance: CanvasBrushLine | CanvasEraserLine | CanvasRect | CanvasImage | CanvasTransformer
|
instance:
|
||||||
|
| CanvasBrushLine
|
||||||
|
| CanvasEraserLine
|
||||||
|
| CanvasRect
|
||||||
|
| CanvasImage
|
||||||
|
| CanvasTransformer
|
||||||
|
| CanvasLayer
|
||||||
|
| CanvasStagingArea
|
||||||
): GetLoggingContext => {
|
): GetLoggingContext => {
|
||||||
return (extra?: JSONObject): JSONObject => {
|
if (instance instanceof CanvasLayer || instance instanceof CanvasStagingArea) {
|
||||||
return {
|
return (extra?: JSONObject): JSONObject => {
|
||||||
...instance.parent.getLoggingContext(),
|
return {
|
||||||
objectId: instance.id,
|
...instance.manager.getLoggingContext(),
|
||||||
...extra,
|
entityId: instance.id,
|
||||||
|
...extra,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
} else {
|
||||||
};
|
return (extra?: JSONObject): JSONObject => {
|
||||||
|
return {
|
||||||
buildEntityGetLoggingContext = (instance: CanvasLayer | CanvasStagingArea): GetLoggingContext => {
|
...instance.parent.getLoggingContext(),
|
||||||
return (extra?: JSONObject): JSONObject => {
|
objectId: instance.id,
|
||||||
return {
|
...extra,
|
||||||
...instance.manager.getLoggingContext(),
|
};
|
||||||
entityId: instance.id,
|
|
||||||
...extra,
|
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
logDebugInfo() {
|
logDebugInfo() {
|
||||||
|
@ -28,7 +28,7 @@ export class CanvasRect {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.manager = parent.manager;
|
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 = this.manager.buildLogger(this.getLoggingContext);
|
||||||
this.log.trace({ state }, 'Creating rect');
|
this.log.trace({ state }, 'Creating rect');
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ export class CanvasStagingArea {
|
|||||||
constructor(manager: CanvasManager) {
|
constructor(manager: CanvasManager) {
|
||||||
this.id = getPrefixedId(CanvasStagingArea.TYPE);
|
this.id = getPrefixedId(CanvasStagingArea.TYPE);
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
this.getLoggingContext = this.manager.buildEntityGetLoggingContext(this);
|
this.getLoggingContext = this.manager.buildGetLoggingContext(this);
|
||||||
this.log = this.manager.buildLogger(this.getLoggingContext);
|
this.log = this.manager.buildLogger(this.getLoggingContext);
|
||||||
this.log.debug('Creating staging area');
|
this.log.debug('Creating staging area');
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ export class CanvasTransformer {
|
|||||||
this.manager = parent.manager;
|
this.manager = parent.manager;
|
||||||
this.transformTarget = transformTarget;
|
this.transformTarget = transformTarget;
|
||||||
|
|
||||||
this.getLoggingContext = this.manager.buildObjectGetLoggingContext(this);
|
this.getLoggingContext = this.manager.buildGetLoggingContext(this);
|
||||||
this.log = this.manager.buildLogger(this.getLoggingContext);
|
this.log = this.manager.buildLogger(this.getLoggingContext);
|
||||||
this.subscriptions = [];
|
this.subscriptions = [];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user