@@ -612,7 +612,9 @@ export class LogFileWatcher {
612612 if ( fs . existsSync ( serviceDir ) ) {
613613 // Ensure .logs directory exists so watcher can subscribe immediately
614614 const logsDir = ensureLogsDir ( serviceDir ) ;
615- watchPaths . push ( path . join ( logsDir , '*.log' ) ) ;
615+ // Watch the directory itself, not glob pattern - more reliable
616+ const watchPath = logsDir . replace ( / \\ / g, '/' ) ;
617+ watchPaths . push ( watchPath ) ;
616618 }
617619 }
618620
@@ -621,21 +623,35 @@ export class LogFileWatcher {
621623 return ;
622624 }
623625
626+ console . log ( chalk . cyan ( '[LogWatcher] Watch paths:' ) , watchPaths ) ;
627+
624628 // Initialize cache with current logs
625629 await this . loadInitialLogs ( cfg . services ) ;
626630
627- // Start chokidar watcher
631+ // Start chokidar watcher - watch directories, filter for .log files in handlers
628632 this . watcher = chokidar . watch ( watchPaths , {
629- ignored : / ( ^ | [ \/ \\ ] ) \. . / , // ignore dotfiles
633+ ignored : [ '**/node_modules/**' , '**/.git/**' , '**/.DS_Store' ] ,
630634 persistent : true ,
631- ignoreInitial : false
635+ ignoreInitial : false ,
636+ usePolling : true , // Enable polling for more reliable file watching on Windows
637+ interval : 1000 , // Poll every second
638+ depth : 0 // Only watch files in the immediate directory, not subdirectories
632639 } ) ;
633640
634641 this . watcher
635- . on ( 'add' , ( filePath ) => this . handleFileChange ( 'add' , filePath ) )
636- . on ( 'change' , ( filePath ) => this . handleFileChange ( 'change' , filePath ) )
637- . on ( 'unlink' , ( filePath ) => this . handleFileChange ( 'unlink' , filePath ) )
638- . on ( 'error' , ( error ) => console . error ( 'Log watcher error:' , error ) ) ;
642+ . on ( 'add' , ( filePath ) => {
643+ if ( ! filePath . endsWith ( '.log' ) ) return ; // Only process .log files
644+ this . handleFileChange ( 'add' , filePath ) ;
645+ } )
646+ . on ( 'change' , ( filePath ) => {
647+ if ( ! filePath . endsWith ( '.log' ) ) return ; // Only process .log files
648+ this . handleFileChange ( 'change' , filePath ) ;
649+ } )
650+ . on ( 'unlink' , ( filePath ) => {
651+ if ( ! filePath . endsWith ( '.log' ) ) return ; // Only process .log files
652+ this . handleFileChange ( 'unlink' , filePath ) ;
653+ } )
654+ . on ( 'error' , ( error ) => console . error ( chalk . red ( 'Log watcher error:' ) , error ) ) ;
639655
640656 this . isWatching = true ;
641657 console . log ( chalk . green ( '📁 Started watching log files with chokidar' ) ) ;
@@ -678,7 +694,9 @@ export class LogFileWatcher {
678694 async handleFileChange ( event , filePath ) {
679695 try {
680696 const serviceName = this . getServiceNameFromLogPath ( filePath ) ;
681- if ( ! serviceName ) return ;
697+ if ( ! serviceName ) {
698+ return ;
699+ }
682700
683701 if ( event === 'unlink' ) {
684702 // File deleted - clear cache for this service
0 commit comments