Skip to content

Commit 362d6bf

Browse files
committed
even better compiler logging
1 parent 674e410 commit 362d6bf

File tree

6 files changed

+29
-6
lines changed

6 files changed

+29
-6
lines changed

.changeset/pretty-hounds-invent.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@openfn/compiler': patch
3+
---
4+
5+
Improved log output:
6+
7+
- Don't log anything for import/export statements (consistent with other visitors)
8+
- When a step is compiled, include the step name

.changeset/warm-bananas-cry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@openfn/engine-multi': patch
3+
---
4+
5+
Better logs for compiler

packages/compiler/src/compile.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@ export default function compile(
5151
// write the operations index to the source map
5252
map.operations = (transformedAst.program as any).operations ?? [];
5353

54-
const duration = (Date.now() - start) / 1000;
55-
logger.success(`Compilation complete in ${duration.toPrecision(2)}s`);
54+
const duration = ((Date.now() - start) / 1000).toPrecision(2);
55+
if (options.name) {
56+
logger.info(`Compiled ${name} in ${duration}s`);
57+
} else {
58+
logger.info(`Compilation complete in ${duration}s`);
59+
}
5660

5761
if (options.logCompiledSource) {
5862
logger.debug('Compiled source:');

packages/compiler/src/transforms/add-imports.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export function findAllDanglingIdentifiers(ast: ASTNode) {
156156
return result;
157157
}
158158

159-
function visitor(path: NodePath, logger: Logger, options: AddImportsOptions) {
159+
function visitor(path: NodePath, _logger: Logger, options: AddImportsOptions) {
160160
if (options.adaptors) {
161161
const identifiers = findAllDanglingIdentifiers(path.node);
162162

@@ -180,10 +180,10 @@ function visitor(path: NodePath, logger: Logger, options: AddImportsOptions) {
180180
if (usedExports.length) {
181181
// TODO maybe in trace output we can say WHY we're doing these things
182182
addUsedImports(path, usedExports, name);
183-
logger.debug(`Added import statement for ${name}`);
183+
//logger.debug(`Added import statement for ${name}`);
184184
if (exportAll) {
185185
addExportAdaptor(path, name);
186-
logger.debug(`Added export * statement for ${name}`);
186+
//logger.debug(`Added export * statement for ${name}`);
187187
}
188188
}
189189
}

packages/engine-multi/src/worker/thread/compile.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const compileJob = async (job: Job, logger: Logger, repoDir?: string) => {
4747
const { expression, adaptors, linker } = job;
4848
const compilerOptions: Options = {
4949
logger,
50+
name: job.name,
5051
};
5152
if (adaptors && repoDir) {
5253
const adaptorConfig = [];

packages/engine-multi/src/worker/thread/run.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,15 @@ register({
8181
publish(COMPILE_START, {
8282
workflowId: plan.id,
8383
});
84+
logger.info('Compiling all workflow steps...');
8485
await compile(plan, { repoDir }, logger);
86+
const duration = Date.now() - start;
87+
logger.success(
88+
`Workflow compilation complete in ${(duration / 1000).toPrecision(2)}s`
89+
);
8590
publish(COMPILE_COMPLETE, {
8691
workflowId: plan.id,
87-
duration: Date.now() - start,
92+
duration,
8893
});
8994
return run(plan, input, options);
9095
});

0 commit comments

Comments
 (0)