fix: show logs better
This commit is contained in:
@@ -472,7 +472,6 @@ export const saveBuildLog = async ({
|
|||||||
|
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
console.debug(`[${applicationId}] ${addTimestamp}`);
|
console.debug(`[${applicationId}] ${addTimestamp}`);
|
||||||
return
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return await got.post(`${fluentBitUrl}/${applicationId}_buildlog_${buildId}.csv`, {
|
return await got.post(`${fluentBitUrl}/${applicationId}_buildlog_${buildId}.csv`, {
|
||||||
@@ -480,7 +479,8 @@ export const saveBuildLog = async ({
|
|||||||
line: encrypt(line)
|
line: encrypt(line)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch(error) {
|
} catch (error) {
|
||||||
|
if (isDev) return
|
||||||
return await prisma.buildLog.create({
|
return await prisma.buildLog.create({
|
||||||
data: {
|
data: {
|
||||||
line: addTimestamp, buildId, time: Number(day().valueOf()), applicationId
|
line: addTimestamp, buildId, time: Number(day().valueOf()), applicationId
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
let fromDb = false;
|
let fromDb = false;
|
||||||
let cancelInprogress = false;
|
let cancelInprogress = false;
|
||||||
let position = 0;
|
let position = 0;
|
||||||
|
let loading = true;
|
||||||
const { id } = $page.params;
|
const { id } = $page.params;
|
||||||
|
|
||||||
const cleanAnsiCodes = (str: string) => str.replace(/\x1B\[(\d+)m/g, '');
|
const cleanAnsiCodes = (str: string) => str.replace(/\x1B\[(\d+)m/g, '');
|
||||||
@@ -46,6 +47,7 @@
|
|||||||
}
|
}
|
||||||
async function streamLogs(sequence = 0) {
|
async function streamLogs(sequence = 0) {
|
||||||
try {
|
try {
|
||||||
|
loading = true;
|
||||||
let {
|
let {
|
||||||
logs: responseLogs,
|
logs: responseLogs,
|
||||||
status,
|
status,
|
||||||
@@ -60,6 +62,7 @@
|
|||||||
|
|
||||||
streamInterval = setInterval(async () => {
|
streamInterval = setInterval(async () => {
|
||||||
if (status !== 'running' && status !== 'queued') {
|
if (status !== 'running' && status !== 'queued') {
|
||||||
|
loading = false;
|
||||||
clearInterval(streamInterval);
|
clearInterval(streamInterval);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -75,6 +78,7 @@
|
|||||||
logs = logs.concat(
|
logs = logs.concat(
|
||||||
data.logs.map((log: any) => ({ ...log, line: cleanAnsiCodes(log.line) }))
|
data.logs.map((log: any) => ({ ...log, line: cleanAnsiCodes(log.line) }))
|
||||||
);
|
);
|
||||||
|
loading = false;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return errorNotification(error);
|
return errorNotification(error);
|
||||||
}
|
}
|
||||||
@@ -171,13 +175,13 @@
|
|||||||
<div
|
<div
|
||||||
bind:this={logsEl}
|
bind:this={logsEl}
|
||||||
on:scroll={detect}
|
on:scroll={detect}
|
||||||
class="font-mono w-full bg-coolgray-100 border border-coolgray-200 p-5 overflow-x-auto overflox-y-auto max-h-[80vh] rounded mb-20 flex flex-col scrollbar-thumb-coollabs scrollbar-track-coolgray-200 scrollbar-w-1"
|
class="font-mono w-full bg-coolgray-100 border border-coolgray-200 p-5 overflow-x-auto overflox-y-auto max-h-[80vh] rounded mb-20 flex flex-col scrollbar-thumb-coollabs scrollbar-track-coolgray-200 scrollbar-w-1 whitespace-pre"
|
||||||
>
|
>
|
||||||
{#each logs as log}
|
{#each logs as log}
|
||||||
{#if fromDb}
|
{#if fromDb}
|
||||||
<div>{log.line + '\n'}</div>
|
{log.line + '\n'}
|
||||||
{:else}
|
{:else}
|
||||||
<div>[{day.unix(log.time).format('HH:mm:ss.SSS')}] {log.line + '\n'}</div>
|
[{day.unix(log.time).format('HH:mm:ss.SSS')}] {log.line + '\n'}
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
@@ -185,6 +189,10 @@
|
|||||||
<div
|
<div
|
||||||
class="font-mono w-full bg-coolgray-200 p-5 overflow-x-auto overflox-y-auto max-h-[80vh] rounded mb-20 flex flex-col whitespace-nowrap scrollbar-thumb-coollabs scrollbar-track-coolgray-200 scrollbar-w-1"
|
class="font-mono w-full bg-coolgray-200 p-5 overflow-x-auto overflox-y-auto max-h-[80vh] rounded mb-20 flex flex-col whitespace-nowrap scrollbar-thumb-coollabs scrollbar-track-coolgray-200 scrollbar-w-1"
|
||||||
>
|
>
|
||||||
{dev ? 'In development, logs are shown in the console.' : 'No logs found yet.'}
|
{loading
|
||||||
|
? 'Loading logs...'
|
||||||
|
: dev
|
||||||
|
? 'In development, logs are shown in the console.'
|
||||||
|
: 'No logs found yet.'}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
Reference in New Issue
Block a user