@@ -240,19 +240,29 @@ class LogProcessor {
240
240
}
241
241
242
242
formatLogMessage ( logEntries , config ) {
243
- const lines = logEntries . map ( entry => {
244
- const timestamp = new Date ( entry . timestamp ) . toLocaleTimeString ( ) ;
245
- return `[${ timestamp } ] ${ entry . pod } /${ entry . container } : ${ entry . line } ` ;
246
- } ) ;
247
-
248
- // Determine the highest log level in the buffer
249
243
const levels = logEntries . map ( entry => this . extractLogLevel ( entry . line ) ) ;
250
244
const highestLevel = this . getHighestLogLevel ( levels ) ;
251
-
252
245
const { header, color } = this . getLevelFormatting ( highestLevel , config ) ;
253
- const logContent = lines . join ( '\n' ) ;
254
-
255
- return `${ header } \`\`\`\n${ logContent } \n\`\`\`` ;
246
+ const logContent = logEntries . map ( entry => {
247
+ const timestamp = new Date ( entry . timestamp ) . toLocaleTimeString ( ) ;
248
+ return `*[${ timestamp } ]* \`${ entry . pod } /${ entry . container } \`: ${ entry . line } ` ;
249
+ } ) . join ( '\n' ) ;
250
+ const podInfo = `*Pod:* \`${ config . podName } \`\n*Namespace:* \`${ config . namespace } \`` ;
251
+ return {
252
+ text : `${ header } \n${ logContent } ` ,
253
+ blocks : [
254
+ { type : 'header' , text : { type : 'plain_text' , text : header . replace ( / [ * _ ` ] / g, '' ) , emoji : true } } ,
255
+ { type : 'section' , fields : [
256
+ { type : 'mrkdwn' , text : podInfo } ,
257
+ { type : 'mrkdwn' , text : `*Log Level:* ${ highestLevel . toUpperCase ( ) } ` }
258
+ ] } ,
259
+ { type : 'divider' } ,
260
+ { type : 'section' , text : { type : 'mrkdwn' , text : `\n\n\`\`\`${ logContent } \`\`\`` } } ,
261
+ { type : 'context' , elements : [
262
+ { type : 'mrkdwn' , text : `:clock1: Sent at ${ new Date ( ) . toLocaleString ( ) } ` }
263
+ ] }
264
+ ]
265
+ } ;
256
266
}
257
267
258
268
getHighestLogLevel ( levels ) {
@@ -529,35 +539,31 @@ class LogProcessor {
529
539
formatConsolidationMessage ( patternData ) {
530
540
const duration = Math . round ( ( Date . now ( ) - patternData . lastSeen ) / 1000 ) ;
531
541
const level = this . extractLogLevel ( patternData . pattern ) ;
532
- const baseInfo = `${ patternData . config . podName } (${ patternData . config . namespace } )` ;
533
-
534
- // Use different emojis and titles based on the log level
535
- let emoji , title ;
542
+ const baseInfo = `*Pod:* \`${ patternData . config . podName } \`\n*Namespace:* \`${ patternData . config . namespace } \`` ;
543
+ let emoji , title , color ;
536
544
switch ( level ) {
537
- case 'error' :
538
- emoji = '🔄' ;
539
- title = 'Repeated Error Pattern' ;
540
- break ;
541
- case 'warn' :
542
- emoji = '🔄' ;
543
- title = 'Repeated Warning Pattern' ;
544
- break ;
545
- case 'debug' :
546
- emoji = '🔄' ;
547
- title = 'Repeated Debug Pattern' ;
548
- break ;
549
- case 'info' :
550
- default :
551
- emoji = '🔄' ;
552
- title = 'Repeated Info Pattern' ;
553
- break ;
545
+ case 'error' : emoji = '🔄' ; title = 'Repeated Error Pattern' ; color = '#e01e5a' ; break ;
546
+ case 'warn' : emoji = '🔄' ; title = 'Repeated Warning Pattern' ; color = '#ecb22e' ; break ;
547
+ case 'debug' : emoji = '🔄' ; title = 'Repeated Debug Pattern' ; color = '#2eb886' ; break ;
548
+ case 'info' : default : emoji = '🔄' ; title = 'Repeated Info Pattern' ; color = '#36c5f0' ; break ;
554
549
}
555
-
556
- const header = `${ emoji } *${ title } * - ${ baseInfo } \n` ;
557
- const summary = `*Pattern repeated ${ patternData . count } times* over ${ duration } seconds\n` ;
558
- const pattern = `*Pattern:* \`${ patternData . pattern } \`` ;
559
-
560
- return `${ header } ${ summary } ${ pattern } ` ;
550
+ return {
551
+ text : `${ emoji } ${ title } - ${ patternData . config . podName } ` ,
552
+ blocks : [
553
+ { type : 'header' , text : { type : 'plain_text' , text : `${ emoji } ${ title } ` , emoji : true } } ,
554
+ { type : 'section' , fields : [
555
+ { type : 'mrkdwn' , text : baseInfo } ,
556
+ { type : 'mrkdwn' , text : `*Log Level:* ${ level . toUpperCase ( ) } ` } ,
557
+ { type : 'mrkdwn' , text : `*Count:* ${ patternData . count } ` } ,
558
+ { type : 'mrkdwn' , text : `*Duration:* ${ duration } seconds` }
559
+ ] } ,
560
+ { type : 'divider' } ,
561
+ { type : 'section' , text : { type : 'mrkdwn' , text : `*Pattern:*\n\`\`\`${ patternData . pattern } \`\`\`` } } ,
562
+ { type : 'context' , elements : [
563
+ { type : 'mrkdwn' , text : `:clock1: Last seen at ${ new Date ( patternData . lastSeen ) . toLocaleString ( ) } ` }
564
+ ] }
565
+ ]
566
+ } ;
561
567
}
562
568
563
569
scheduleStoppedMessage ( patternKey , patternData ) {
@@ -595,35 +601,30 @@ class LogProcessor {
595
601
596
602
formatStoppedMessage ( patternData ) {
597
603
const level = this . extractLogLevel ( patternData . pattern ) ;
598
- const baseInfo = `${ patternData . config . podName } (${ patternData . config . namespace } )` ;
599
-
600
- // Use different emojis based on the log level
601
- let emoji , title ;
604
+ const baseInfo = `*Pod:* \`${ patternData . config . podName } \`\n*Namespace:* \`${ patternData . config . namespace } \`` ;
605
+ let emoji , title , color ;
602
606
switch ( level ) {
603
- case 'error' :
604
- emoji = '✅' ;
605
- title = 'Error Pattern Resolved' ;
606
- break ;
607
- case 'warn' :
608
- emoji = '✅' ;
609
- title = 'Warning Pattern Resolved' ;
610
- break ;
611
- case 'debug' :
612
- emoji = '🔍' ;
613
- title = 'Debug Pattern Stopped' ;
614
- break ;
615
- case 'info' :
616
- default :
617
- emoji = 'ℹ️' ;
618
- title = 'Info Pattern Stopped' ;
619
- break ;
607
+ case 'error' : emoji = '✅' ; title = 'Error Pattern Resolved' ; color = '#2eb886' ; break ;
608
+ case 'warn' : emoji = '✅' ; title = 'Warning Pattern Resolved' ; color = '#2eb886' ; break ;
609
+ case 'debug' : emoji = '🔍' ; title = 'Debug Pattern Stopped' ; color = '#36c5f0' ; break ;
610
+ case 'info' : default : emoji = 'ℹ️' ; title = 'Info Pattern Stopped' ; color = '#36c5f0' ; break ;
620
611
}
621
-
622
- const header = `${ emoji } *${ title } * - ${ baseInfo } \n` ;
623
- const summary = `*Pattern stopped repeating* after ${ patternData . count } occurrences\n` ;
624
- const pattern = `*Pattern:* \`${ patternData . pattern } \`` ;
625
-
626
- return `${ header } ${ summary } ${ pattern } ` ;
612
+ return {
613
+ text : `${ emoji } ${ title } - ${ patternData . config . podName } ` ,
614
+ blocks : [
615
+ { type : 'header' , text : { type : 'plain_text' , text : `${ emoji } ${ title } ` , emoji : true } } ,
616
+ { type : 'section' , fields : [
617
+ { type : 'mrkdwn' , text : baseInfo } ,
618
+ { type : 'mrkdwn' , text : `*Log Level:* ${ level . toUpperCase ( ) } ` } ,
619
+ { type : 'mrkdwn' , text : `*Total Occurrences:* ${ patternData . count } ` }
620
+ ] } ,
621
+ { type : 'divider' } ,
622
+ { type : 'section' , text : { type : 'mrkdwn' , text : `*Pattern:*\n\`\`\`${ patternData . pattern } \`\`\`` } } ,
623
+ { type : 'context' , elements : [
624
+ { type : 'mrkdwn' , text : `:white_check_mark: Resolved at ${ new Date ( ) . toLocaleString ( ) } ` }
625
+ ] }
626
+ ]
627
+ } ;
627
628
}
628
629
629
630
checkForStoppedPatterns ( streamKey ) {
0 commit comments