Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show partial logs during compilation process #40

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading