@@ -313,12 +313,18 @@ describe('util.ts', () => {
313313 afterEach ( ( ) => {
314314 delete process . env . GOOGLE_SDK_NODE_LOGGING ;
315315 delete process . env . GOOGLE_SDK_NODE_EXPERIMENTAL_LOGGING ;
316+ delete process . env . GOOGLE_SDK_NODE_CLIENT_SERVICE ;
317+ delete process . env . GCP_CLIENT_SERVICE ;
316318 } ) ;
317319
318320 const mockSettings = new CallSettings ( {
319321 enableTelemetryLogging : true ,
320322 } ) ;
321323
324+ const storageSettings = new CallSettings ( {
325+ apiName : 'google.cloud.storage.v1.Storage' ,
326+ } ) ;
327+
322328 it ( 'returns false when GOOGLE_SDK_NODE_EXPERIMENTAL_LOGGING is not set even if logging is enabled' , ( ) => {
323329 process . env . GOOGLE_SDK_NODE_LOGGING = 'true' ;
324330 assert . strictEqual ( checkLoggingEnabled ( mockSettings ) , false ) ;
@@ -353,54 +359,69 @@ describe('util.ts', () => {
353359 assert . strictEqual ( checkLoggingEnabled ( undefined ) , false ) ;
354360 } ) ;
355361
356- it ( 'returns true when GOOGLE_SDK_NODE_EXPERIMENTAL_LOGGING=true and GOOGLE_SDK_NODE_LOGGING=true' , ( ) => {
357- process . env . GOOGLE_SDK_NODE_EXPERIMENTAL_LOGGING = 'true' ;
358- process . env . GOOGLE_SDK_NODE_LOGGING = 'true' ;
359- assert . strictEqual ( checkLoggingEnabled ( new CallSettings ( { } ) ) , true ) ;
360- assert . strictEqual ( checkLoggingEnabled ( ) , true ) ;
361- } ) ;
362-
363- it ( 'accepts GOOGLE_SDK_NODE_LOGGING and GOOGLE_SDK_NODE_EXPERIMENTAL_LOGGING case-insensitively' , ( ) => {
362+ it ( 'returns true when GOOGLE_SDK_NODE_LOGGING is true, 1, all, or * (case-insensitively)' , ( ) => {
364363 process . env . GOOGLE_SDK_NODE_EXPERIMENTAL_LOGGING = 'TRUE' ;
365- process . env . GOOGLE_SDK_NODE_LOGGING = 'TRUE' ;
366- assert . strictEqual ( checkLoggingEnabled ( new CallSettings ( { } ) ) , true ) ;
364+ for ( const value of [ 'true' , 'TRUE' , '1' , 'all' , 'ALL' , '*' ] ) {
365+ process . env . GOOGLE_SDK_NODE_LOGGING = value ;
366+ assert . strictEqual ( checkLoggingEnabled ( storageSettings ) , true ) ;
367+ assert . strictEqual ( checkLoggingEnabled ( new CallSettings ( { } ) ) , true ) ;
368+ assert . strictEqual ( checkLoggingEnabled ( ) , true ) ;
369+ }
367370 } ) ;
368371
369- it ( 'returns false when GOOGLE_SDK_NODE_LOGGING=false or 0 overrides the client option ' , ( ) => {
372+ it ( 'matches comma-separated and wildcard namespace filters against client service or google-gax fallback ' , ( ) => {
370373 process . env . GOOGLE_SDK_NODE_EXPERIMENTAL_LOGGING = 'true' ;
371- process . env . GOOGLE_SDK_NODE_LOGGING = 'false' ;
372- assert . strictEqual ( checkLoggingEnabled ( mockSettings ) , false ) ;
373374
374- process . env . GOOGLE_SDK_NODE_LOGGING = '0 ' ;
375- assert . strictEqual ( checkLoggingEnabled ( mockSettings ) , false ) ;
376- } ) ;
375+ process . env . GOOGLE_SDK_NODE_LOGGING = 'storage ' ;
376+ assert . strictEqual ( checkLoggingEnabled ( storageSettings ) , true ) ;
377+ assert . strictEqual ( checkLoggingEnabled ( new CallSettings ( { } ) ) , false ) ;
377378
378- it ( 'returns true when GOOGLE_SDK_NODE_LOGGING=true or 1 overrides enableTelemetryLogging=false on settings' , ( ) => {
379- process . env . GOOGLE_SDK_NODE_EXPERIMENTAL_LOGGING = 'true' ;
380- const disabledSettings = new CallSettings ( {
381- enableTelemetryLogging : false ,
382- } ) ;
379+ process . env . GOOGLE_SDK_NODE_LOGGING = 'auth,STORAGE,bigquery' ;
380+ assert . strictEqual ( checkLoggingEnabled ( storageSettings ) , true ) ;
383381
384- process . env . GOOGLE_SDK_NODE_LOGGING = 'true ' ;
385- assert . strictEqual ( checkLoggingEnabled ( disabledSettings ) , true ) ;
382+ process . env . GOOGLE_SDK_NODE_LOGGING = 'auth, stor* ' ;
383+ assert . strictEqual ( checkLoggingEnabled ( storageSettings ) , true ) ;
386384
387- process . env . GOOGLE_SDK_NODE_LOGGING = '1' ;
388- assert . strictEqual ( checkLoggingEnabled ( disabledSettings ) , true ) ;
389- } ) ;
385+ process . env . GOOGLE_SDK_NODE_LOGGING = 'auth,bigquery' ;
386+ assert . strictEqual ( checkLoggingEnabled ( storageSettings ) , false ) ;
390387
391- it ( 'falls back to the client option when GOOGLE_SDK_NODE_LOGGING is empty or whitespace' , ( ) => {
392- process . env . GOOGLE_SDK_NODE_EXPERIMENTAL_LOGGING = ' true' ;
393- process . env . GOOGLE_SDK_NODE_LOGGING = '' ;
394- assert . strictEqual ( checkLoggingEnabled ( mockSettings ) , true ) ;
388+ process . env . GOOGLE_SDK_NODE_LOGGING = 'google-gax' ;
389+ assert . strictEqual ( checkLoggingEnabled ( new CallSettings ( { } ) ) , true ) ;
390+ assert . strictEqual ( checkLoggingEnabled ( ) , true ) ;
391+ assert . strictEqual ( checkLoggingEnabled ( storageSettings ) , false ) ;
395392
396- process . env . GOOGLE_SDK_NODE_LOGGING = ' ' ;
397- assert . strictEqual ( checkLoggingEnabled ( mockSettings ) , true ) ;
393+ process . env . GOOGLE_SDK_NODE_CLIENT_SERVICE = 'custom.svc' ;
394+ process . env . GOOGLE_SDK_NODE_LOGGING = 'custom.svc' ;
395+ assert . strictEqual ( checkLoggingEnabled ( storageSettings ) , true ) ;
396+ process . env . GOOGLE_SDK_NODE_LOGGING = 'customXsvc' ;
397+ assert . strictEqual ( checkLoggingEnabled ( storageSettings ) , false ) ;
398398 } ) ;
399399
400- it ( 'treats an unrecognized GOOGLE_SDK_NODE_LOGGING value as disabled ' , ( ) => {
400+ it ( 'combines GOOGLE_SDK_NODE_LOGGING and enableTelemetryLogging with logical OR ' , ( ) => {
401401 process . env . GOOGLE_SDK_NODE_EXPERIMENTAL_LOGGING = 'true' ;
402- process . env . GOOGLE_SDK_NODE_LOGGING = 'yes' ;
403- assert . strictEqual ( checkLoggingEnabled ( mockSettings ) , false ) ;
402+ const disabledStorageSettings = new CallSettings ( {
403+ apiName : 'google.cloud.storage.v1.Storage' ,
404+ enableTelemetryLogging : false ,
405+ } ) ;
406+
407+ // Matching GOOGLE_SDK_NODE_LOGGING enables logging even when client option is false.
408+ for ( const value of [ 'true' , '1' , 'all' , '*' , 'auth,storage' ] ) {
409+ process . env . GOOGLE_SDK_NODE_LOGGING = value ;
410+ assert . strictEqual ( checkLoggingEnabled ( disabledStorageSettings ) , true ) ;
411+ }
412+
413+ // Non-matching or false/0 GOOGLE_SDK_NODE_LOGGING does not disable explicit enableTelemetryLogging: true.
414+ for ( const value of [ 'auth' , 'false' , '0' , '' , ' ' ] ) {
415+ process . env . GOOGLE_SDK_NODE_LOGGING = value ;
416+ assert . strictEqual ( checkLoggingEnabled ( mockSettings ) , true ) ;
417+ }
418+
419+ // false, 0, and non-matching filters stay disabled when client option is not enabled.
420+ for ( const value of [ 'false' , '0' , 'yes' ] ) {
421+ process . env . GOOGLE_SDK_NODE_LOGGING = value ;
422+ assert . strictEqual ( checkLoggingEnabled ( disabledStorageSettings ) , false ) ;
423+ assert . strictEqual ( checkLoggingEnabled ( storageSettings ) , false ) ;
424+ }
404425 } ) ;
405426
406427 it ( 'does not throw when process is undefined, as in a browser' , ( ) => {
0 commit comments