alf: the atproto Latency Fabric alf.fly.dev/
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 39 lines 1.0 kB view raw
1// ABOUTME: Pino-based structured logger for ALF (Atproto Latency Fabric) service 2 3import pino from 'pino'; 4 5const isTestEnv = process.env.NODE_ENV === 'test'; 6const enableTestLogging = process.env.ENABLE_TEST_LOGGING === 'true'; 7 8export const rootLogger = pino({ 9 level: process.env.LOG_LEVEL ?? 'info', 10 enabled: !isTestEnv || enableTestLogging, 11}); 12 13interface LogContext { 14 [key: string]: string | number | boolean | null | undefined; 15} 16 17export class Logger { 18 private child: pino.Logger; 19 20 constructor(module: string) { 21 this.child = rootLogger.child({ module }); 22 } 23 24 info(message: string, context?: LogContext): void { 25 this.child.info(context ?? {}, message); 26 } 27 28 warn(message: string, context?: LogContext): void { 29 this.child.warn(context ?? {}, message); 30 } 31 32 error(message: string, error?: Error, context?: LogContext): void { 33 this.child.error({ err: error, ...context }, message); 34 } 35} 36 37export function createLogger(module: string): Logger { 38 return new Logger(module); 39}