Skip to content

Commit 5110419

Browse files
committed
Better log formatting
1 parent 87bfe71 commit 5110419

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
"**/Thumbs.db": true,
1111
".github": false,
1212
".vscode": false
13-
}
13+
},
14+
"typescript.tsdk": "node_modules/typescript/lib"
1415
}

lambdas/api-handler/src/config/deps.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,15 @@ function createMIRepository(
5959
}
6060

6161
export function createDependenciesContainer(): Deps {
62-
const log = pino();
62+
const log = pino({
63+
level: envVars.PINO_LOG_LEVEL || "info",
64+
formatters: {
65+
level: (label) => {
66+
return { level: label.toUpperCase() };
67+
},
68+
},
69+
timestamp: () => `,"timestamp":"${new Date(Date.now()).toISOString()}"`,
70+
});
6371

6472
return {
6573
s3Client: new S3Client(),

lambdas/api-handler/src/config/env.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const EnvVarsSchema = z.object({
1010
DOWNLOAD_URL_TTL_SECONDS: z.coerce.number().int(),
1111
MAX_LIMIT: z.coerce.number().int().optional(),
1212
QUEUE_URL: z.coerce.string().optional(),
13+
PINO_LOG_LEVEL: z.coerce.string().optional(),
1314
});
1415

1516
export type EnvVars = z.infer<typeof EnvVarsSchema>;

0 commit comments

Comments
 (0)