Skip to content

Commit 25a6346

Browse files
committed
Add debug logger
1 parent 82018e4 commit 25a6346

File tree

3 files changed

+33
-17
lines changed

3 files changed

+33
-17
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"colors": "1.4.0",
6565
"crypto-js": "4.2.0",
6666
"date-fns": "3.6.0",
67+
"debug": "^4.4.1",
6768
"elkjs": "0.9.3",
6869
"globals": "^16.0.0",
6970
"gsap": "3.12.5",

pnpm-lock.yaml

Lines changed: 18 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/hooks/landscape-data-watcher.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import { useConfigurationStore } from 'explorviz-frontend/src/stores/configurati
66
import { useLandscapeRestructureStore } from '../stores/landscape-restructure';
77
import { useIdeWebsocketFacadeStore } from '../stores/ide-websocket-facade';
88
import { useApplicationRepositoryStore } from 'explorviz-frontend/src/stores/repos/application-repository';
9-
import ApplicationData, { K8sData } from 'explorviz-frontend/src/utils/application-data';
9+
import ApplicationData, {
10+
K8sData,
11+
} from 'explorviz-frontend/src/utils/application-data';
1012
import computeClassCommunication, {
1113
computeRestructuredClassCommunication,
1214
} from 'explorviz-frontend/src/utils/application-rendering/class-communication-computer';
@@ -35,12 +37,14 @@ import LandscapeModel from 'explorviz-frontend/src/view-objects/3d/landscape/lan
3537
import layoutLandscape from 'explorviz-frontend/src/utils/elk-layouter';
3638
import { useShallow } from 'zustand/react/shallow';
3739
import { updateHighlighting } from '../utils/application-rendering/highlighting';
40+
import debug from 'debug';
3841

3942
export default function useLandscapeDataWatcher(
4043
landscapeData: LandscapeData | null,
4144
landscape3D: Landscape3D
4245
) {
4346
// MARK: Stores
47+
const log = debug('app:hooks:useLandscapeWatcher');
4448

4549
const applicationRendererState = useApplicationRendererStore(
4650
useShallow((state) => ({
@@ -143,6 +147,7 @@ export default function useLandscapeDataWatcher(
143147
};
144148

145149
const handleUpdatedLandscapeData = async () => {
150+
log('handleUpdateLandscape');
146151
await Promise.resolve();
147152
if (!structureLandscapeData || !dynamicLandscapeData || !landscape3D) {
148153
return;
@@ -156,10 +161,13 @@ export default function useLandscapeDataWatcher(
156161

157162
// Applications might be removed in evolution mode
158163
if (applications.length !== applicationRepositoryState.applications.size) {
164+
console.log('Remove all applications from landscape3D');
159165
landscape3D.removeAll();
160166
}
161167

168+
log('Layouting landscape ...');
162169
const boxLayoutMap = await layoutLandscape(k8sNodes, applications);
170+
log('Layouted landscape.');
163171

164172
// Set data model for landscape
165173
const landscapeLayout = boxLayoutMap.get('landscape');
@@ -172,19 +180,23 @@ export default function useLandscapeDataWatcher(
172180
}
173181

174182
// ToDo: This can take quite some time. Optimize.
183+
log('Compute class communication');
175184
let classCommunications = computeClassCommunication(
176185
structureLandscapeData,
177186
dynamicLandscapeData
178187
);
188+
log('Computed class communication');
179189

180190
if (landscapeRestructureState.restructureMode) {
191+
console.log('Computing restructured communication ...');
181192
classCommunications = computeRestructuredClassCommunication(
182193
classCommunications,
183194
landscapeRestructureState.createdClassCommunication,
184195
landscapeRestructureState.copiedClassCommunications,
185196
landscapeRestructureState.updatedClassCommunications,
186197
landscapeRestructureState.completelyDeletedClassCommunications
187198
);
199+
console.log('Computed restructured communication.');
188200
}
189201
landscapeRestructureState.setAllClassCommunications(classCommunications);
190202

@@ -208,7 +220,7 @@ export default function useLandscapeDataWatcher(
208220
const k8sApp3Ds: ApplicationObject3D[] = [];
209221

210222
// Add k8sApps
211-
for(const k8sData of k8sAppData) {
223+
for (const k8sData of k8sAppData) {
212224
const applicationData = await updateApplicationData(
213225
k8sData.app,
214226
{

0 commit comments

Comments
 (0)