@@ -5,15 +5,15 @@ import * as cp from 'child_process';
55import which from 'which' ;
66
77import * as vscode from 'vscode' ;
8- import { LoggingService } from '../services/logging-service ' ;
8+ import { Logger } from '../services/logging' ;
99import { FortranDocumentSelector , resolveVariables } from '../lib/tools' ;
1010import * as fg from 'fast-glob' ;
1111import { glob } from 'glob' ;
1212import { arraysEqual } from '../lib/helper' ;
1313import { RescanLint } from './commands' ;
1414
1515export class FortranLintingProvider {
16- constructor ( private logger : LoggingService = new LoggingService ( ) ) { }
16+ constructor ( private logger : Logger = new Logger ( ) ) { }
1717
1818 private diagnosticCollection : vscode . DiagnosticCollection ;
1919 private compiler : string ;
@@ -88,6 +88,7 @@ export class FortranLintingProvider {
8888 env . Path = `${ path . dirname ( command ) } ${ path . delimiter } ${ env . Path } ` ;
8989 }
9090 }
91+ this . logger . info ( `[lint] Compiler query command line: ${ command } ${ argList . join ( ' ' ) } ` ) ;
9192 const childProcess = cp . spawn ( command , argList , {
9293 cwd : filePath ,
9394 env : env ,
@@ -101,11 +102,13 @@ export class FortranLintingProvider {
101102 compilerOutput += data ;
102103 } ) ;
103104 childProcess . stderr . on ( 'end' , ( ) => {
105+ this . logger . debug ( `[lint] Compiler output:\n${ compilerOutput } ` ) ;
104106 let diagnostics = this . getLinterResults ( compilerOutput ) ;
105107 diagnostics = [ ...new Map ( diagnostics . map ( v => [ JSON . stringify ( v ) , v ] ) ) . values ( ) ] ;
106108 this . diagnosticCollection . set ( textDocument . uri , diagnostics ) ;
107109 } ) ;
108110 childProcess . on ( 'error' , err => {
111+ this . logger . error ( `[lint] Compiler error:` , err ) ;
109112 console . log ( `ERROR: ${ err } ` ) ;
110113 } ) ;
111114 } else {
@@ -167,7 +170,7 @@ export class FortranLintingProvider {
167170 }
168171
169172 modout = resolveVariables ( modout ) ;
170- this . logger . logInfo ( `Linter. moduleOutput: ${ modFlag } ${ modout } `) ;
173+ this . logger . debug ( `[lint] moduleOutput: ${ modFlag } ${ modout } `) ;
171174 return [ modFlag , modout ] ;
172175 }
173176
@@ -195,7 +198,7 @@ export class FortranLintingProvider {
195198 // Update our cache input
196199 this . cache [ 'includePaths' ] = includePaths ;
197200 // Output the original include paths
198- this . logger . logInfo ( `Linter. include:\n ${ includePaths . join ( '\r\n' ) } ` ) ;
201+ if ( includePaths . length > 0 ) this . logger . debug ( `[lint] include:` , includePaths ) ;
199202 // Resolve internal variables and expand glob patterns
200203 const resIncludePaths = includePaths . map ( e => resolveVariables ( e ) ) ;
201204 // fast-glob cannot work with Windows paths
@@ -212,12 +215,12 @@ export class FortranLintingProvider {
212215 // Try to recover from fast-glob failing due to EACCES using slower more
213216 // robust glob.
214217 } catch ( eacces ) {
215- this . logger . logWarning ( ` You lack read permissions for an include directory
218+ this . logger . warn ( `[lint] You lack read permissions for an include directory
216219 or more likely a glob match from the input 'includePaths' list. This can happen when
217220 using overly broad root level glob patters e.g. /usr/lib/** .
218221 No reason to worry. I will attempt to recover.
219222 You should consider adjusting your 'includePaths' if linting performance is slow.` ) ;
220- this . logger . logWarning ( ` ${ eacces . message } `) ;
223+ this . logger . warn ( `[lint] ${ eacces . message } `) ;
221224 try {
222225 const globIncPaths : string [ ] = [ ] ;
223226 for ( const i of resIncludePaths ) {
@@ -228,7 +231,7 @@ export class FortranLintingProvider {
228231 return globIncPaths ;
229232 // if we failed again then our includes are somehow wrong. Abort
230233 } catch ( error ) {
231- this . logger . logError ( `Failed to recover: ${ error } `) ;
234+ this . logger . error ( `[lint] Include path glob resolution failed to recover: ${ error } `) ;
232235 }
233236 }
234237 }
@@ -243,7 +246,7 @@ export class FortranLintingProvider {
243246 this . compiler = config . get < string > ( 'compiler' , 'gfortran' ) ;
244247 this . compilerPath = config . get < string > ( 'compilerPath' , '' ) ;
245248 if ( this . compilerPath === '' ) this . compilerPath = which . sync ( this . compiler ) ;
246- this . logger . logInfo ( `using linter: ${ this . compiler } located in: ${ this . compilerPath } `) ;
249+ this . logger . debug ( `[lint] binary: " ${ this . compiler } " located in: " ${ this . compilerPath } " `) ;
247250 return this . compilerPath ;
248251 }
249252
@@ -287,7 +290,7 @@ export class FortranLintingProvider {
287290 const lnStr : string = ln === - 1 ? 'none' : ln . toString ( ) ;
288291 args . push ( `-ffree-line-length-${ lnStr } ` , `-ffixed-line-length-${ lnStr } ` ) ;
289292 }
290- this . logger . logInfo ( `Linter. arguments:\n ${ args . join ( '\r\n' ) } ` ) ;
293+ if ( args . length > 0 ) this . logger . debug ( `[lint] arguments:` , args ) ;
291294
292295 // Resolve internal variables but do not apply glob pattern matching
293296 return args . map ( e => resolveVariables ( e ) ) ;
@@ -540,7 +543,10 @@ export class FortranLintingProvider {
540543 * Regenerate the cache for the include files paths of the linter
541544 */
542545 private rescanLinter ( ) {
546+ this . logger . debug ( `[lint] Resetting linter include paths cache` ) ;
547+ this . logger . debug ( `[lint] Current linter include paths cache:` , this . cache [ 'includePaths' ] ) ;
543548 this . cache [ 'includePaths' ] = [ ] ;
544549 this . getIncludePaths ( ) ;
550+ this . logger . debug ( `[lint] New linter include paths cache:` , this . cache [ 'includePaths' ] ) ;
545551 }
546552}
0 commit comments