* 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
)
| 264 | * @returns the MongoDBLogWritable object to write logs to |
| 265 | */ |
| 266 | function 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 | |
| 291 | function resolveSeverityConfiguration( |
| 292 | clientOption: string | undefined, |
no test coverage detected