MCPcopy
hub / github.com/mongodb/node-mongodb-native / resolveLogPath

Function resolveLogPath

src/mongo_logger.ts:266–289  ·  view source on GitHub ↗

* resolves the MONGODB_LOG_PATH and mongodbLogPath options from the environment and the * mongo client options respectively. The mongodbLogPath can be either 'stdout', 'stderr', a NodeJS * Writable or an object which has a `write` method with the signature: * ```ts * write(log: Log): void * ```

(
  { MONGODB_LOG_PATH }: MongoLoggerEnvOptions,
  { mongodbLogPath }: MongoLoggerMongoClientOptions
)

Source from the content-addressed store, hash-verified

264 * @returns the MongoDBLogWritable object to write logs to
265 */
266function resolveLogPath(
267 { MONGODB_LOG_PATH }: MongoLoggerEnvOptions,
268 { mongodbLogPath }: MongoLoggerMongoClientOptions
269): { mongodbLogPath: MongoDBLogWritable; mongodbLogPathIsStdErr: boolean } {
270 if (typeof mongodbLogPath === 'string' && /^stderr$/i.test(mongodbLogPath)) {
271 return { mongodbLogPath: createStdioLogger(process.stderr), mongodbLogPathIsStdErr: true };
272 }
273 if (typeof mongodbLogPath === 'string' && /^stdout$/i.test(mongodbLogPath)) {
274 return { mongodbLogPath: createStdioLogger(process.stdout), mongodbLogPathIsStdErr: false };
275 }
276
277 if (typeof mongodbLogPath === 'object' && typeof mongodbLogPath?.write === 'function') {
278 return { mongodbLogPath: mongodbLogPath, mongodbLogPathIsStdErr: false };
279 }
280
281 if (MONGODB_LOG_PATH && /^stderr$/i.test(MONGODB_LOG_PATH)) {
282 return { mongodbLogPath: createStdioLogger(process.stderr), mongodbLogPathIsStdErr: true };
283 }
284 if (MONGODB_LOG_PATH && /^stdout$/i.test(MONGODB_LOG_PATH)) {
285 return { mongodbLogPath: createStdioLogger(process.stdout), mongodbLogPathIsStdErr: false };
286 }
287
288 return { mongodbLogPath: createStdioLogger(process.stderr), mongodbLogPathIsStdErr: true };
289}
290
291function resolveSeverityConfiguration(
292 clientOption: string | undefined,

Callers 1

resolveOptionsMethod · 0.85

Calls 2

createStdioLoggerFunction · 0.85
testMethod · 0.80

Tested by

no test coverage detected