MCPcopy Index your code
hub / github.com/freeCodeCamp/freeCodeCamp / getLogger

Function getLogger

api/src/utils/logger.ts:95–118  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

93 * @returns A logger instance.
94 */
95export const getLogger = () => {
96 const isPretty = FCC_API_LOG_TRANSPORT === 'pretty';
97 const options: LoggerOptions = {
98 level: FCC_API_LOG_LEVEL || 'info',
99 serializers
100 };
101
102 if (isPretty) {
103 const stream = transport({ targets: [prettyTarget] }) as
104 | DestinationStream
105 | undefined;
106
107 return pino(options, stream);
108 } else {
109 // For non-pretty, use the custom de-duplicating transform stream
110 // This logger will write to a stream that then pipes to our de-duplicator
111 const deduplicator = new DeduplicatingTransform();
112 // Pino writes NDJSON, so our transform needs to handle that.
113 // The pino instance itself doesn't need a complex transport, it writes to the stream.
114 const logger = pino(options, deduplicator);
115 deduplicator.pipe(process.stdout);
116 return logger;
117 }
118};

Callers 1

app.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected