differentiate between db logs and not

This commit is contained in:
Andras Bacsai 2022-09-15 10:03:38 +02:00
parent 83508f165d
commit 1f232d96d8
2 changed files with 14 additions and 5 deletions

View File

@ -1206,6 +1206,7 @@ export async function getBuildIdLogs(request: FastifyRequest<GetBuildIdLogs>) {
log.time = Number(log.time)
return log
}),
fromDb: true,
took: day().diff(createdAt) / 1000,
status: data?.status || 'queued'
}
@ -1221,6 +1222,7 @@ export async function getBuildIdLogs(request: FastifyRequest<GetBuildIdLogs>) {
}).filter(log => log.time > sequence)
return {
logs,
fromDb: false,
took: day().diff(createdAt) / 1000,
status: data?.status || 'queued'
}

View File

@ -18,7 +18,7 @@
let followingBuild: any;
let followingInterval: any;
let logsEl: any;
let fromDb = false;
let cancelInprogress = false;
const { id } = $page.params;
@ -38,13 +38,16 @@
}
async function streamLogs(sequence = 0) {
try {
let { logs: responseLogs, status } = await get(
`/applications/${id}/logs/build/${buildId}?sequence=${sequence}`
);
let {
logs: responseLogs,
status,
fromDb: from
} = await get(`/applications/${id}/logs/build/${buildId}?sequence=${sequence}`);
currentStatus = status;
logs = logs.concat(
responseLogs.map((log: any) => ({ ...log, line: cleanAnsiCodes(log.line) }))
);
fromDb = from;
streamInterval = setInterval(async () => {
if (status !== 'running' && status !== 'queued') {
clearInterval(streamInterval);
@ -159,7 +162,11 @@
bind:this={logsEl}
>
{#each logs as log}
<div>[{day.unix(log.time).format('HH:mm:ss.SSS')}] {log.line + '\n'}</div>
{#if fromDb}
<div>[{day.unix(log.time).format('HH:mm:ss.SSS')}] {log.line + '\n'}</div>
{:else}
<div>{log.line + '\n'}</div>
{/if}
{/each}
</div>
{:else}