Skip to content

Commit

Permalink
feat: show partial logs during compilation process
Browse files Browse the repository at this point in the history
  • Loading branch information
javiersuweijie committed Oct 16, 2024
1 parent 6938f8e commit ea8852f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions packages/app/src/components/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ export const Item = (props: {entry: Entry}) => {
async function pendingOrCompleted(status: string) {
// const icon = (status === "COMPLETED") ? <CheckCircle color="green" className="w-5 h-5 mr-2"/> : <Hourglass color="gray" className="w-5 h-5 mr-2"/>;
let icon;
let logs;
switch (status) {
case "COMPLETED":
icon = <CheckCircle color="green" className="w-5 h-5 mr-2"/>;
break;
case "ERROR":
const logs = await getLogs(entry.slug);
logs = await getLogs(entry.slug);
icon = <SimpleDialog trigger={<div><XCircle color="red" className="w-6 h-6 mr-2"/></div>} title={"Error logs"} wide={true}>
<div>
<pre>{logs.codeLog}</pre>
Expand All @@ -38,7 +39,13 @@ export const Item = (props: {entry: Entry}) => {
</SimpleDialog>
break;
default:
icon = <Hourglass color="gray" className="w-5 h-5 mr-2"/>;
logs = await getLogs(entry.slug);
icon = <SimpleDialog trigger={<div><Hourglass color="gray" className="w-5 h-5 mr-2"/></div>} title={"Pending logs"} wide={true}>
<div>
<pre>{logs.codeLog}</pre>
<pre>{logs.circuitLog}</pre>
</div>
</SimpleDialog>
}
let tooltip = tooltips[status];
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/lib/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as fs from 'fs';

export function log(file: string, message: string, service: string = '') {
const date = new Date().toISOString();
const cleanedMessage = `${message}`.replace(/\x1b\[[0-9;]*[mGKH]/g, '');
const cleanedMessage = `${message}`.replace(/\x1b\[[0-9;]*[mGKH]/g, '').trimEnd();
for (const line of cleanedMessage.split('\n')) {
fs.writeFileSync(file, `[${service}] ${date} - ${line}\r\n`, { flag: 'a+' });
}
Expand Down

0 comments on commit ea8852f

Please sign in to comment.