File tree Expand file tree Collapse file tree 1 file changed +8
-13
lines changed
test/tools/unified-spec-runner Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -178,27 +178,22 @@ export class UnifiedMongoClient extends MongoClient {
178
178
serverDescriptionChangedEvent : 'serverDescriptionChanged'
179
179
} as const ;
180
180
181
+ static LOGGING_COMPONENT_TO_ENV_VAR_NAME = {
182
+ command : 'MONGODB_LOG_COMMAND' ,
183
+ serverSelection : 'MONGODB_LOG_SERVER_SELECTION' ,
184
+ connection : 'MONGODB_LOG_CONNECTION' ,
185
+ topology : 'MONGODB_LOG_TOPOLOGY'
186
+ } as const ;
187
+
181
188
constructor ( uri : string , description : ClientEntity ) {
182
189
const logCollector = new UnifiedLogCollector ( ) ;
183
190
const componentSeverities = {
184
191
MONGODB_LOG_ALL : 'off'
185
192
} ;
186
- const camelToUpperSnake = ( s : string ) => {
187
- const output : string [ ] = [ ] ;
188
- for ( const c of s ) {
189
- if ( / [ A - Z ] / . test ( c ) ) {
190
- output . push ( '_' ) ;
191
- output . push ( c ) ;
192
- } else {
193
- output . push ( c ) ;
194
- }
195
- }
196
- return output . join ( '' ) . toUpperCase ( ) ;
197
- } ;
198
193
199
194
// NOTE: this is done to override the logger environment variables
200
195
for ( const key in description . observeLogMessages ) {
201
- componentSeverities [ 'MONGODB_LOG_' + camelToUpperSnake ( key ) ] =
196
+ componentSeverities [ UnifiedMongoClient . LOGGING_COMPONENT_TO_ENV_VAR_NAME [ key ] ] =
202
197
description . observeLogMessages [ key ] ;
203
198
}
204
199
You can’t perform that action at this time.
0 commit comments