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

Function initLogger

packages/logging/src/init-logger.ts:26–52  ·  view source on GitHub ↗
(slug: string)

Source from the content-addressed store, hash-verified

24 * @returns Pino logger instance (or no-op logger on failure)
25 */
26export function initLogger(slug: string): Logger {
27 const cached = loggerCache.get(slug);
28
29 if (cached) {
30 return cached.logger;
31 }
32
33 try {
34 const logFilePath = `${LOG_DIR}/${slug}.log`;
35
36 const config: LoggerConfig = {
37 slug,
38 logDir: LOG_DIR,
39 logFilePath,
40 };
41
42 const logger = createLogger(config);
43
44 loggerCache.set(slug, { logger, config });
45
46 return logger;
47 } catch (error) {
48 // Log initialization failed - return a no-op logger to prevent CLI crashes
49 // The CLI will continue to work, but logging will be silently disabled
50 return createNoOpLogger();
51 }
52}
53
54/**
55 * Create a logger with automatic log rotation.

Callers 1

Calls 4

createLoggerFunction · 0.85
createNoOpLoggerFunction · 0.85
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected