MCPcopy
hub / github.com/lingodotdev/lingo.dev / createLogger

Function createLogger

packages/logging/src/init-logger.ts:57–87  ·  view source on GitHub ↗

* Create a logger with automatic log rotation.

(config: LoggerConfig)

Source from the content-addressed store, hash-verified

55 * Create a logger with automatic log rotation.
56 */
57function createLogger(config: LoggerConfig): Logger {
58 const logFileName = basename(config.logFilePath);
59
60 // Create rotating file stream with smart defaults
61 const stream = createStream(logFileName, {
62 size: LOG_ROTATION_MAX_SIZE, // Rotate at 10MB
63 interval: LOG_ROTATION_INTERVAL, // Daily rotation
64 maxFiles: LOG_ROTATION_MAX_FILES, // Keep 10 files
65 compress: LOG_ROTATION_COMPRESS, // Gzip old files
66 path: config.logDir, // Directory for logs
67 });
68
69 // Handle runtime errors on the stream to prevent crashes
70 stream.on("error", (err) => {
71 // Log to stderr so errors are visible but don't crash the CLI
72 console.error(`[Logger error]: ${err.message}`);
73 });
74
75 const logger = pino(
76 {
77 level: DEFAULT_LOG_LEVEL,
78 redact: {
79 paths: [...DEFAULT_REDACT_PATHS],
80 censor: "[REDACTED]",
81 },
82 },
83 stream,
84 );
85
86 return logger;
87}
88
89/**
90 * Create a no-op logger that discards all log messages.

Callers 1

initLoggerFunction · 0.85

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected