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

Method resolveOptions

src/mongo_logger.ts:1026–1080  ·  view source on GitHub ↗

* Merges options set through environment variables and the MongoClient, preferring environment * variables when both are set, and substituting defaults for values not set. Options set in * constructor take precedence over both environment variables and MongoClient options. * * @remarks

(
    envOptions: MongoLoggerEnvOptions,
    clientOptions: MongoLoggerMongoClientOptions
  )

Source from the content-addressed store, hash-verified

1024 * @returns a MongoLoggerOptions object to be used when instantiating a new MongoLogger
1025 */
1026 static resolveOptions(
1027 envOptions: MongoLoggerEnvOptions,
1028 clientOptions: MongoLoggerMongoClientOptions
1029 ): MongoLoggerOptions {
1030 // client options take precedence over env options
1031 const resolvedLogPath = resolveLogPath(envOptions, clientOptions);
1032 const combinedOptions = {
1033 ...envOptions,
1034 ...clientOptions,
1035 mongodbLogPath: resolvedLogPath.mongodbLogPath,
1036 mongodbLogPathIsStdErr: resolvedLogPath.mongodbLogPathIsStdErr
1037 };
1038 const defaultSeverity = resolveSeverityConfiguration(
1039 combinedOptions.mongodbLogComponentSeverities?.default,
1040 combinedOptions.MONGODB_LOG_ALL,
1041 SeverityLevel.OFF
1042 );
1043
1044 return {
1045 componentSeverities: {
1046 command: resolveSeverityConfiguration(
1047 combinedOptions.mongodbLogComponentSeverities?.command,
1048 combinedOptions.MONGODB_LOG_COMMAND,
1049 defaultSeverity
1050 ),
1051 topology: resolveSeverityConfiguration(
1052 combinedOptions.mongodbLogComponentSeverities?.topology,
1053 combinedOptions.MONGODB_LOG_TOPOLOGY,
1054 defaultSeverity
1055 ),
1056 serverSelection: resolveSeverityConfiguration(
1057 combinedOptions.mongodbLogComponentSeverities?.serverSelection,
1058 combinedOptions.MONGODB_LOG_SERVER_SELECTION,
1059 defaultSeverity
1060 ),
1061 connection: resolveSeverityConfiguration(
1062 combinedOptions.mongodbLogComponentSeverities?.connection,
1063 combinedOptions.MONGODB_LOG_CONNECTION,
1064 defaultSeverity
1065 ),
1066 client: resolveSeverityConfiguration(
1067 combinedOptions.mongodbLogComponentSeverities?.client,
1068 combinedOptions.MONGODB_LOG_CLIENT,
1069 defaultSeverity
1070 ),
1071 default: defaultSeverity
1072 },
1073 maxDocumentLength:
1074 combinedOptions.mongodbLogMaxDocumentLength ??
1075 parseUnsignedInteger(combinedOptions.MONGODB_LOG_MAX_DOCUMENT_LENGTH) ??
1076 1000,
1077 logDestination: combinedOptions.mongodbLogPath,
1078 logDestinationIsStdErr: combinedOptions.mongodbLogPathIsStdErr
1079 };
1080 }
1081}

Callers 2

parseOptionsFunction · 0.80

Calls 3

parseUnsignedIntegerFunction · 0.90
resolveLogPathFunction · 0.85

Tested by

no test coverage detected