Skip to content

Commit 9ea650b

Browse files
committed
Fix log appending logic in LogViewer.svelte
1 parent ce0a755 commit 9ea650b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/lib/LogViewer.svelte

+8-1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
return;
108108
}
109109
logs = [];
110+
110111
updates.listen({
111112
input: { app: app, job: job, env: env, team: team, instances: instances }
112113
});
@@ -128,8 +129,14 @@
128129
updates.unlisten();
129130
return;
130131
}
132+
console.log(new Date().toUTCString() + ' result: ' + JSON.stringify(result.data.log));
131133
console.log(new Date().toUTCString() + ' before append: ' + logs.length);
132-
logs = [...logs.slice(-maxLines), result.data.log];
134+
if (logs.length < maxLines) {
135+
logs = [...logs.slice(), result.data.log];
136+
} else {
137+
logs = [...logs.slice(-maxLines), result.data.log];
138+
}
139+
133140
console.log(new Date().toUTCString() + ' after append: ' + logs.length);
134141
}
135142
logs.sort((a, b) => a.time.getTime() - b.time.getTime());

0 commit comments

Comments
 (0)