Skip to content

Commit 37b27a5

Browse files
committed
fix: improve logging in output writers
1 parent c00002f commit 37b27a5

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/services/output/BaseWriter.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import type { Config } from "../../config/index.js";
22
import { DI } from "../../di.js";
3+
import type { ILogger } from "../../log/index.js";
4+
import { Logger } from "../../log/index.js";
35
import { json_stringify } from "../../utils/bigint-serializer.js";
46
import type { OptimisticResults } from "../liquidate/index.js";
57

68
export default class BaseWriter {
9+
@Logger("OutputWriter")
10+
log!: ILogger;
11+
712
@DI.Inject(DI.Config)
813
config!: Config;
914

src/services/output/fileWriter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ export default class FileWriter
1111
public async write(): Promise<void> {
1212
const filename = join(this.config.outDir, this.filename);
1313
try {
14+
this.log.debug(`writing to ${filename}`);
1415
await writeFile(filename, this.content, "utf-8");
1516
} catch (e) {
16-
console.error(e);
17+
this.log.error(e, `failed to write to ${filename}`);
1718
}
1819
}
1920
}

src/services/output/s3Writer.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default class S3Writer
1313
const key = join(this.config.outS3Prefix, this.filename);
1414
const client = new S3Client({});
1515
try {
16+
this.log.debug(`uploading to s3://${this.config.outS3Bucket}/${key}`);
1617
await client.send(
1718
new PutObjectCommand({
1819
Bucket: this.config.outS3Bucket,
@@ -22,7 +23,10 @@ export default class S3Writer
2223
}),
2324
);
2425
} catch (e) {
25-
console.error(e);
26+
this.log.error(
27+
e,
28+
`failed to upload to s3://${this.config.outS3Bucket}/${key}`,
29+
);
2630
}
2731
}
2832
}

0 commit comments

Comments
 (0)