feat: switch logging to pino

Closes HP-279
This commit is contained in:
Aarnav Tale
2026-06-17 15:58:48 -04:00
parent 57c8046f99
commit 3252482e0b
8 changed files with 292 additions and 27 deletions
+18 -3
View File
@@ -19,16 +19,31 @@ import {
import { extname, normalize, resolve, sep } from "node:path";
import mime from "mime";
import pino from "pino";
export interface Logger {
info: (msg: string, ...args: unknown[]) => void;
error: (msg: string, ...args: unknown[]) => void;
}
// TODO: Replace with Pino!
const runtimeDestination = pino.destination({ dest: 1, sync: false });
process.on("exit", () => runtimeDestination.flushSync());
const runtimePino = pino(
{
base: { service: "headplane" },
messageKey: "message",
timestamp: () => `,"timestamp":"${new Date().toISOString()}"`,
formatters: {
level: (label) => ({ level: label }),
},
},
runtimeDestination,
);
const defaultLogger: Logger = {
info: (msg, ...args) => console.log(`[runtime] ${msg}`, ...args),
error: (msg, ...args) => console.error(`[runtime] ${msg}`, ...args),
info: (msg, ...args) => runtimePino.info({ component: "runtime" }, msg, ...args),
error: (msg, ...args) => runtimePino.error({ component: "runtime" }, msg, ...args),
};
export interface StaticOptions {