Skip to content

Commit

Permalink
Merge pull request #412 from stakwork/fix/log-copy
Browse files Browse the repository at this point in the history
fix: setup logs properly
  • Loading branch information
Evanfeenstra authored Nov 25, 2024
2 parents daf7062 + 59c84ce commit 26d6528
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions app/src/nodes/NodeLogs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,25 @@
let open = false;
export let nodeName = "";
let logs = [];
let logs = "";
function cleanLog(log) {
return log.replace(/\x1B\[[0-9;]*m/g, ""); // Remove ANSI escape codes
}
async function getNodeLogs() {
open = true;
const theLogs = await api.swarm.get_logs(`${nodeName}.sphinx`);
if (theLogs) logs = theLogs.reverse();
if (theLogs) {
logs = "";
for (let i = 0; i < theLogs.length; i++) {
logs = `${logs}${cleanLog(theLogs[i])}`;
}
}
}
onDestroy(() => {
logs = [];
logs = "";
});
</script>

Expand All @@ -34,9 +43,7 @@
</section>
<section class="modal-content">
<div class="logs">
{#each logs as log}
<div class="log">{log}</div>
{/each}
<pre class="log">{logs}</pre>
</div>
</section>
</div>
Expand Down Expand Up @@ -93,8 +100,11 @@
flex-direction: column-reverse;
}
.log {
color: white;
margin: 1px 0;
font-family: monospace;
font-size: 0.8rem;
background-color: #1e1e1e;
color: white;
padding: 1rem;
white-space: pre-wrap;
}
</style>

0 comments on commit 26d6528

Please sign in to comment.