Skip to content

Commit b4fbf33

Browse files
committed
Refactor logging messages for Tomcat startup and log syntax highlighting
1 parent db52a70 commit b4fbf33

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/services/Logger.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,10 @@ export class Logger {
373373
return null;
374374
}
375375

376+
if (cleanLine.includes('Server startup in')) {
377+
return ['SUCCESS', cleanLine.replace(/.*?(Server startup in.*)/, '$1').replace('Server startup in [', 'Tomcat started in ').replace('] milliseconds', 'ms')];
378+
}
379+
376380
const levelMap: { [key: string]: string } = {
377381
'SEVERE': 'ERROR',
378382
'WARNING': 'WARN',
@@ -386,10 +390,6 @@ export class Logger {
386390
return [mappedLevel, message];
387391
}
388392

389-
if (cleanLine.includes('Server startup in')) {
390-
return ['INFO', cleanLine.replace(/.*?(Server startup in.*)/, '$1')];
391-
}
392-
393393
if (cleanLine.match(/GET|POST|PUT|DELETE/)) {
394394
const httpMessage = cleanLine
395395
.replace(/(\d+)\s*ms$/, '')

src/services/Tomcat.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ export class Tomcat {
128128

129129
try {
130130
this.executeTomcatCommand('start', tomcatHome, javaHome);
131-
logger.success('Tomcat started successfully', showMessages);
131+
if (showMessages) {
132+
logger.info('Tomcat started successfully', showMessages);
133+
}
132134
} catch (err) {
133135
logger.error('Failed to start Tomcat:', showMessages, err as string);
134136
}

syntaxes/tomcat-log.tmLanguage.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
},
8686
{
8787
"name": "support.type.log-level.info.tomcat",
88-
"match": "(\\INFO|\\HTTP)",
88+
"match": "\\b(INFO|HTTP|APP)\\b",
8989
"captures": {
9090
"1": {
9191
"name": "support.type.log-level.info.tomcat"
@@ -112,7 +112,7 @@
112112
},
113113
{
114114
"name": "support.type.log-level.success.tomcat",
115-
"match": "\\b(SUCCESS|APP)\\b",
115+
"match": "\\b(SUCCESS)\\b",
116116
"captures": {
117117
"1": {
118118
"name": "support.type.log-level.success.tomcat"

0 commit comments

Comments
 (0)