Skip to content

Commit aaed9b6

Browse files
committed
fix: improve logging in output writers
1 parent aaa3746 commit aaed9b6

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/services/output/BaseWriter.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ import { json_stringify } from "@gearbox-protocol/sdk";
22

33
import type { Config } from "../../config/index.js";
44
import { DI } from "../../di.js";
5+
import { type ILogger, Logger } from "../../log/index.js";
56
import type { OptimisticResults } from "../liquidate/index.js";
67

78
export default class BaseWriter {
9+
@Logger("OutputWriter")
10+
log!: ILogger;
11+
812
@DI.Inject(DI.Config)
913
config!: Config;
1014

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)