Skip to content

Commit ef11a17

Browse files
committed
Merge branch 'main' of https://github.com/Al-rimi/tomcat
2 parents 3eb07b3 + 8a77aab commit ef11a17

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "tomcat",
33
"displayName": "Tomcat",
44
"description": "Fully Automated Support for Apache Tomcat",
5-
"version": "2.5.2",
5+
"version": "2.5.3",
66
"publisher": "Al-rimi",
77
"author": {
88
"email": "[email protected]",

src/services/Builder.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ export class Builder {
186186
await action();
187187
}
188188

189+
// Register a keyword callback in the Logger
190+
logger.onKeyword('毫秒后服务器启动', () => {
191+
Browser.getInstance().run(appName); // Start the browser
192+
});
193+
189194
logger.defaultStatusBar();
190195

191196
const endTime = performance.now();
@@ -196,7 +201,6 @@ export class Builder {
196201
await new Promise(resolve => setTimeout(resolve, 50));
197202
await tomcat.reload();
198203
await new Promise(resolve => setTimeout(resolve, 100));
199-
Browser.getInstance().run(appName);
200204
}
201205

202206
this.attempts = 0;

src/services/Logger.ts

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)