Skip to content

Commit a7c8776

Browse files
committed
fix(debug): Handle different arg types in Log
Arguments in the Log pane were rendered using a method that assumed they were always a string, an array, or undefined. This commit uses a more robust approach to stringifying them to avoid errors. Fixes #923
1 parent 2373438 commit a7c8776

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/client/debug/log/LogEvent.svelte

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
const dispatch = createEventDispatcher();
1212
1313
const args = action.payload.args;
14-
const renderedArgs = typeof args === 'string' ? args : (args || []).join(',');
14+
const renderedArgs = Array.isArray(args)
15+
? args.map(arg => JSON.stringify(arg, null, 2)).join(',')
16+
: JSON.stringify(args, null, 2) || '';
1517
const playerID = action.payload.playerID;
1618
let actionType;
1719
switch (action.type) {
@@ -59,6 +61,11 @@
5961
opacity: 1;
6062
}
6163
64+
.args {
65+
text-align: left;
66+
white-space: pre-wrap;
67+
}
68+
6269
.player0 {
6370
border-left-color: #ff851b;
6471
}
@@ -133,7 +140,7 @@
133140
on:mouseleave={() => dispatch('mouseleave')}
134141
on:blur={() => dispatch('mouseleave')}
135142
>
136-
<div>{actionType}({renderedArgs})</div>
143+
<div class="args">{actionType}({renderedArgs})</div>
137144
{#if metadataComponent}
138145
<svelte:component this={metadataComponent} {metadata} />
139146
{:else}

0 commit comments

Comments
 (0)