@@ -5,15 +5,15 @@ import * as cp from 'child_process';
5
5
import which from 'which' ;
6
6
7
7
import * as vscode from 'vscode' ;
8
- import { LoggingService } from '../services/logging-service ' ;
8
+ import { Logger } from '../services/logging' ;
9
9
import { FortranDocumentSelector , resolveVariables } from '../lib/tools' ;
10
10
import * as fg from 'fast-glob' ;
11
11
import { glob } from 'glob' ;
12
12
import { arraysEqual } from '../lib/helper' ;
13
13
import { RescanLint } from './commands' ;
14
14
15
15
export class FortranLintingProvider {
16
- constructor ( private logger : LoggingService = new LoggingService ( ) ) { }
16
+ constructor ( private logger : Logger = new Logger ( ) ) { }
17
17
18
18
private diagnosticCollection : vscode . DiagnosticCollection ;
19
19
private compiler : string ;
@@ -88,6 +88,7 @@ export class FortranLintingProvider {
88
88
env . Path = `${ path . dirname ( command ) } ${ path . delimiter } ${ env . Path } ` ;
89
89
}
90
90
}
91
+ this . logger . info ( `[lint] Compiler query command line: ${ command } ${ argList . join ( ' ' ) } ` ) ;
91
92
const childProcess = cp . spawn ( command , argList , {
92
93
cwd : filePath ,
93
94
env : env ,
@@ -101,11 +102,13 @@ export class FortranLintingProvider {
101
102
compilerOutput += data ;
102
103
} ) ;
103
104
childProcess . stderr . on ( 'end' , ( ) => {
105
+ this . logger . debug ( `[lint] Compiler output:\n${ compilerOutput } ` ) ;
104
106
let diagnostics = this . getLinterResults ( compilerOutput ) ;
105
107
diagnostics = [ ...new Map ( diagnostics . map ( v => [ JSON . stringify ( v ) , v ] ) ) . values ( ) ] ;
106
108
this . diagnosticCollection . set ( textDocument . uri , diagnostics ) ;
107
109
} ) ;
108
110
childProcess . on ( 'error' , err => {
111
+ this . logger . error ( `[lint] Compiler error:` , err ) ;
109
112
console . log ( `ERROR: ${ err } ` ) ;
110
113
} ) ;
111
114
} else {
@@ -167,7 +170,7 @@ export class FortranLintingProvider {
167
170
}
168
171
169
172
modout = resolveVariables ( modout ) ;
170
- this . logger . logInfo ( `Linter. moduleOutput: ${ modFlag } ${ modout } `) ;
173
+ this . logger . debug ( `[lint] moduleOutput: ${ modFlag } ${ modout } `) ;
171
174
return [ modFlag , modout ] ;
172
175
}
173
176
@@ -195,7 +198,7 @@ export class FortranLintingProvider {
195
198
// Update our cache input
196
199
this . cache [ 'includePaths' ] = includePaths ;
197
200
// 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 ) ;
199
202
// Resolve internal variables and expand glob patterns
200
203
const resIncludePaths = includePaths . map ( e => resolveVariables ( e ) ) ;
201
204
// fast-glob cannot work with Windows paths
@@ -212,12 +215,12 @@ export class FortranLintingProvider {
212
215
// Try to recover from fast-glob failing due to EACCES using slower more
213
216
// robust glob.
214
217
} 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
216
219
or more likely a glob match from the input 'includePaths' list. This can happen when
217
220
using overly broad root level glob patters e.g. /usr/lib/** .
218
221
No reason to worry. I will attempt to recover.
219
222
You should consider adjusting your 'includePaths' if linting performance is slow.` ) ;
220
- this . logger . logWarning ( ` ${ eacces . message } `) ;
223
+ this . logger . warn ( `[lint] ${ eacces . message } `) ;
221
224
try {
222
225
const globIncPaths : string [ ] = [ ] ;
223
226
for ( const i of resIncludePaths ) {
@@ -228,7 +231,7 @@ export class FortranLintingProvider {
228
231
return globIncPaths ;
229
232
// if we failed again then our includes are somehow wrong. Abort
230
233
} catch ( error ) {
231
- this . logger . logError ( `Failed to recover: ${ error } `) ;
234
+ this . logger . error ( `[lint] Include path glob resolution failed to recover: ${ error } `) ;
232
235
}
233
236
}
234
237
}
@@ -243,7 +246,7 @@ export class FortranLintingProvider {
243
246
this . compiler = config . get < string > ( 'compiler' , 'gfortran' ) ;
244
247
this . compilerPath = config . get < string > ( 'compilerPath' , '' ) ;
245
248
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 } " `) ;
247
250
return this . compilerPath ;
248
251
}
249
252
@@ -287,7 +290,7 @@ export class FortranLintingProvider {
287
290
const lnStr : string = ln === - 1 ? 'none' : ln . toString ( ) ;
288
291
args . push ( `-ffree-line-length-${ lnStr } ` , `-ffixed-line-length-${ lnStr } ` ) ;
289
292
}
290
- this . logger . logInfo ( `Linter. arguments:\n ${ args . join ( '\r\n' ) } ` ) ;
293
+ if ( args . length > 0 ) this . logger . debug ( `[lint] arguments:` , args ) ;
291
294
292
295
// Resolve internal variables but do not apply glob pattern matching
293
296
return args . map ( e => resolveVariables ( e ) ) ;
@@ -540,7 +543,10 @@ export class FortranLintingProvider {
540
543
* Regenerate the cache for the include files paths of the linter
541
544
*/
542
545
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' ] ) ;
543
548
this . cache [ 'includePaths' ] = [ ] ;
544
549
this . getIncludePaths ( ) ;
550
+ this . logger . debug ( `[lint] New linter include paths cache:` , this . cache [ 'includePaths' ] ) ;
545
551
}
546
552
}
0 commit comments