fix: logging

This commit is contained in:
Andras Bacsai
2022-09-15 14:27:55 +02:00
parent e9e6449edf
commit f75af035bb
7 changed files with 47 additions and 9 deletions

View File

@@ -472,17 +472,20 @@ export const saveBuildLog = async ({
if (isDev) {
console.debug(`[${applicationId}] ${addTimestamp}`);
}
try {
return await got.post(`${fluentBitUrl}/${applicationId}_buildlog_${buildId}.csv`, {
json: {
line: encrypt(line)
}
})
} catch(error) {
return await prisma.buildLog.create({
data: {
line: addTimestamp, buildId, time: Number(day().valueOf()), applicationId
}
});
}
return await got.post(`${fluentBitUrl}/${applicationId}_buildlog_${buildId}.csv`, {
json: {
line: encrypt(line)
}
})
};

View File

@@ -11,7 +11,7 @@
import Tooltip from '$lib/components/Tooltip.svelte';
import { day } from '$lib/dayjs';
import { selectedBuildId } from '$lib/store';
let logs: any = [];
let currentStatus: any;
let streamInterval: any;
@@ -43,11 +43,13 @@
status,
fromDb: from
} = await get(`/applications/${id}/logs/build/${$selectedBuildId}?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);
@@ -60,7 +62,8 @@
);
status = data.status;
currentStatus = status;
fromDb = data.fromDb;
logs = logs.concat(
data.logs.map((log: any) => ({ ...log, line: cleanAnsiCodes(log.line) }))
);