@@ -231,6 +231,21 @@ Write-Host $LocalizedData.Key2
231231 } ) ;
232232 } ) ;
233233
234+ test ( 'Should have log level configuration' , ( ) => {
235+ const config = vscode . workspace . getConfiguration ( 'powershellLocalization' ) ;
236+
237+ // Test that the log level configuration exists
238+ const logLevel = config . get ( 'logLevel' ) ;
239+ assert . strictEqual ( typeof logLevel , 'string' , 'logLevel should be a string' ) ;
240+
241+ // Check that it's one of the valid values
242+ const validLevels = [ 'error' , 'warn' , 'info' , 'debug' ] ;
243+ assert . ok ( validLevels . includes ( logLevel as string ) , 'logLevel should be one of the valid values' ) ;
244+
245+ // Check default value
246+ assert . strictEqual ( logLevel , 'info' , 'Default log level should be info' ) ;
247+ } ) ;
248+
234249 test ( 'Should respect configuration changes' , async ( ) => {
235250 const config = vscode . workspace . getConfiguration ( 'powershellLocalization' ) ;
236251 const originalValue = config . get ( 'enableInlineValues' ) ;
@@ -430,4 +445,47 @@ function Test-Function {
430445 'No paths should be excluded when patterns array is empty' ) ;
431446 } ) ;
432447 } ) ;
448+
449+ suite ( 'Logger Functionality' , ( ) => {
450+ test ( 'Should respect log level configuration for debug messages' , ( ) => {
451+ // This test verifies the logger respects the log level setting
452+ // Since we can't easily mock the configuration in this test environment,
453+ // we'll test the log level logic conceptually
454+
455+ const logLevels = [ 'error' , 'warn' , 'info' , 'debug' ] ;
456+ const logLevelPriorities = { error : 0 , warn : 1 , info : 2 , debug : 3 } ;
457+
458+ // Test that debug messages should be filtered when log level is info
459+ const currentLevel = 'info' ;
460+ const debugLevel = 'debug' ;
461+
462+ const shouldShowDebug = logLevelPriorities [ debugLevel ] <= logLevelPriorities [ currentLevel ] ;
463+ assert . strictEqual ( shouldShowDebug , false , 'Debug messages should not show when log level is info' ) ;
464+
465+ // Test that info messages should show when log level is info
466+ const infoLevel = 'info' ;
467+ const shouldShowInfo = logLevelPriorities [ infoLevel ] <= logLevelPriorities [ currentLevel ] ;
468+ assert . strictEqual ( shouldShowInfo , true , 'Info messages should show when log level is info' ) ;
469+
470+ // Test that error messages always show
471+ const errorLevel = 'error' ;
472+ const shouldShowError = logLevelPriorities [ errorLevel ] <= logLevelPriorities [ currentLevel ] ;
473+ assert . strictEqual ( shouldShowError , true , 'Error messages should always show' ) ;
474+ } ) ;
475+
476+ test ( 'Should have valid log level hierarchy' , ( ) => {
477+ const logLevels = [ 'error' , 'warn' , 'info' , 'debug' ] ;
478+ const logLevelPriorities = { error : 0 , warn : 1 , info : 2 , debug : 3 } ;
479+
480+ // Verify hierarchy is correct (lower numbers = higher priority)
481+ assert . ok ( logLevelPriorities . error < logLevelPriorities . warn , 'Error should have higher priority than warn' ) ;
482+ assert . ok ( logLevelPriorities . warn < logLevelPriorities . info , 'Warn should have higher priority than info' ) ;
483+ assert . ok ( logLevelPriorities . info < logLevelPriorities . debug , 'Info should have higher priority than debug' ) ;
484+
485+ // Verify all levels are represented
486+ logLevels . forEach ( level => {
487+ assert . ok ( level in logLevelPriorities , `Log level ${ level } should be in priorities` ) ;
488+ } ) ;
489+ } ) ;
490+ } ) ;
433491} ) ;
0 commit comments