Skip to content

Commit

Permalink
Merge pull request #589 from tradingstrategy-ai/588-error-traceback
Browse files Browse the repository at this point in the history
display strategy error traceback when available
  • Loading branch information
kenkunz authored Sep 19, 2023
2 parents cc635b2 + bc061d3 commit 761e27d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Display log messages as a scrollable panel
</script>

<div class="log-panel terminal-viewport">
<!-- reverse mutates the array, so we need to call it on a copy -->
{#each [...logs].reverse() as { timestamp, level, message }}
<LogEntry {timestamp} {level} {message} />
<!-- `reverse()` mutates the original array, so we need to call it on a copy -->
{#each [...logs].reverse() as { timestamp, level, message, formatted_data }}
<LogEntry {timestamp} {level} {message} {formatted_data} />
{/each}
</div>

Expand Down
39 changes: 34 additions & 5 deletions src/routes/strategies/[strategy]/(nav)/logs/LogEntry.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@
export let timestamp: number;
export let level: 'info' | 'trade' | 'warning' | 'error' | 'critical';
export let message: string;
export let formatted_data: Maybe<string[]> = undefined;
</script>

<div class="log-entry level--{level}">
<Timestamp date={timestamp} withSeconds />
<span class="message">
<div class="message">
{message}
</span>
{#if formatted_data?.length}
<details class="traceback">
<summary>
{formatted_data[0].trimEnd()}
<span class="num-lines">({formatted_data.length - 1} lines)</span>
</summary>
{formatted_data.slice(1).join('')}
</details>
{/if}
</div>
</div>

<style lang="postcss">
Expand All @@ -30,15 +40,34 @@
}
.message {
/* display: inline-flex; */
overflow-x: auto;
white-space: pre-line;
font: var(--f-mono-xs-regular);
letter-spacing: var(--f-mono-xs-spacing, normal);
white-space: pre-wrap;
details {
margin-top: 1em;
> summary {
font-weight: bold;
cursor: pointer;
.num-lines {
font-weight: normal;
}
}
&[open] > summary {
.num-lines {
display: none;
}
}
}
}
:global time {
display: flex;
font: var(--f-mono-sm-regular);
letter-spacing: var(--f-mono-sm-spacing, normal);
flex-direction: column;
color: var(--c-text-ultra-light);
Expand Down

0 comments on commit 761e27d

Please sign in to comment.