2
0
forked from jmug/cactoide

feat: add pino logger for serverside

This commit is contained in:
Levente Orban
2025-10-27 09:33:00 +01:00
parent 935042dd06
commit 2a96d3762c
11 changed files with 367 additions and 24 deletions

29
src/lib/logger.ts Normal file
View File

@@ -0,0 +1,29 @@
import pino from 'pino';
import { LOG_PRETTY, LOG_LEVEL } from '$env/static/private';
const USE_PRETTY_LOGS = LOG_PRETTY === 'true';
const transport = USE_PRETTY_LOGS
? {
target: 'pino-pretty',
options: {
colorize: true,
translateTime: 'SYS:standard',
ignore: 'pid,hostname'
}
}
: undefined;
// Create the logger instance
export const logger = pino({
level: LOG_LEVEL,
transport
});
// Export a helper to create child loggers with context
export function createChildLogger(bindings: Record<string, unknown>) {
return logger.child(bindings);
}
// Export types
export type Logger = typeof logger;