@@ -48,8 +48,7 @@ export class LogViewerProvider implements vscode.TreeDataProvider<LogFile>, vsco
4848 public getLogFiles ( dir : string ) : LogFile [ ] {
4949 if ( this . pathExists ( dir ) ) {
5050 const files = fs . readdirSync ( dir ) ;
51- this . updateBadge ( files . length ) ;
52- return files . map ( file => {
51+ const logFiles = files . map ( file => {
5352 const filePath = path . join ( dir , file ) ;
5453 const lineCount = this . getLineCount ( filePath ) ;
5554 const logFile = new LogFile ( `${ file } (${ lineCount } )` , vscode . TreeItemCollapsibleState . Collapsed , {
@@ -61,8 +60,18 @@ export class LogViewerProvider implements vscode.TreeDataProvider<LogFile>, vsco
6160 logFile . children = this . getLogFileLines ( filePath ) ;
6261 return logFile ;
6362 } ) ;
63+ const totalEntries = logFiles . reduce ( ( count , logFile ) => {
64+ return count + ( logFile . children ?. reduce ( ( childCount , child ) => childCount + ( child . children ?. length || 0 ) , 0 ) || 0 ) ;
65+ } , 0 ) ;
66+ const errorEntries = logFiles . reduce ( ( count , logFile ) => {
67+ return count + ( logFile . children ?. reduce ( ( childCount , child ) => {
68+ return childCount + ( child . children ?. filter ( grandChild => grandChild . label . toLowerCase ( ) . includes ( 'error' ) ) . length || 0 ) ;
69+ } , 0 ) || 0 ) ;
70+ } , 0 ) ;
71+ this . updateBadge ( totalEntries , errorEntries ) ;
72+ return logFiles ;
6473 } else {
65- this . updateBadge ( 0 ) ;
74+ this . updateBadge ( 0 , 0 ) ;
6675 return [ ] ;
6776 }
6877 }
@@ -149,8 +158,9 @@ export class LogViewerProvider implements vscode.TreeDataProvider<LogFile>, vsco
149158 return true ;
150159 }
151160
152- private updateBadge ( count : number = 0 ) : void {
153- this . statusBarItem . text = `Magento Logs: ${ count } ` ;
161+ private updateBadge ( totalEntries : number = 0 , errorEntries : number = 0 ) : void {
162+ const entryText = totalEntries === 1 ? 'Magento Log-Entry' : 'Magento Log-Entries' ;
163+ this . statusBarItem . text = `${ entryText } : ${ totalEntries } (${ errorEntries } errors)` ;
154164 }
155165
156166 dispose ( ) {
0 commit comments