@@ -664,18 +664,24 @@ export class Logger {
664664 return dateMatch ? Date . parse ( dateMatch [ 1 ] ) : 0 ;
665665 }
666666
667+ private keywordCallbacks : { keyword : string , callback : ( ) => void } [ ] = [ ] ;
668+
667669 /**
668- * Core logging mechanism
670+ * Register a callback for detecting a specific keyword in logs.
669671 *
670- * Handles log message processing with:
671- * - Level filtering
672- * - Timestamping
673- * - Formatting
674- * - Multi-channel routing
672+ * @param keyword The keyword to detect.
673+ * @param callback The callback to execute when the keyword is detected.
674+ */
675+ public onKeyword ( keyword : string , callback : ( ) => void ) : void {
676+ this . keywordCallbacks . push ( { keyword, callback } ) ;
677+ }
678+
679+ /**
680+ * Core logging mechanism (modified).
675681 *
676- * @param level Log severity level
677- * @param message Log content
678- * @param showUI Optional UI notification callback
682+ * @param level The log severity level.
683+ * @param message The content of the log.
684+ * @param showUI Optional callback to show a UI notification.
679685 */
680686 private log (
681687 level : string ,
@@ -689,7 +695,13 @@ export class Logger {
689695 const timestamp = this . showTimestamp ? `[${ new Date ( ) . toLocaleString ( ) } ] ` : '' ;
690696 const formattedMessage = `${ timestamp } [${ level } ] ${ message } ` ;
691697
692- // Directly append to channel without recursion
698+ // Detect the keyword and trigger the callback
699+ for ( const { keyword, callback } of this . keywordCallbacks ) {
700+ if ( message . includes ( keyword ) ) {
701+ callback ( ) ; // Trigger the callback
702+ }
703+ }
704+
693705 this . outputChannel . appendLine ( formattedMessage ) ;
694706
695707 if ( showUI ) {
0 commit comments