@@ -102,15 +102,18 @@ export class Ext<
102
102
}
103
103
}
104
104
105
- log ( data : string | Buffer | Error ) {
105
+ log ( data : { tag : string ; message : string } | string | Buffer | Error ) {
106
106
if ( typeof data === "string" ) {
107
107
this . outputChannel . appendLine ( data ) ;
108
108
} else if ( data instanceof Error ) {
109
- this . outputChannel . appendLine (
110
- `# [error] ${ data . stack ?? data . message ?? data } `
111
- ) ;
112
- } else {
109
+ this . log ( {
110
+ tag : "error" ,
111
+ message : `${ data . stack ?? data . message ?? data } ` ,
112
+ } ) ;
113
+ } else if ( Buffer . isBuffer ( data ) ) {
113
114
this . outputChannel . appendLine ( uncolorize ( data . toString ( ) ) ) ;
115
+ } else {
116
+ this . outputChannel . appendLine ( `# [${ data . tag } ] ${ data . message } ` ) ;
114
117
}
115
118
}
116
119
@@ -124,7 +127,7 @@ export class Ext<
124
127
125
128
async call ( cb : ( ) => unknown , name = getFunctionName ( cb ) ) {
126
129
try {
127
- this . log ( `[ call: ${ name } ]` ) ;
130
+ this . log ( { tag : " call" , message : name } ) ;
128
131
return await cb ( ) ;
129
132
} catch ( error ) {
130
133
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -197,11 +200,17 @@ export class Ext<
197
200
if ( this . settings . configFileWatcher )
198
201
this . fileWatchers . register (
199
202
this . settings . configPath ??
200
- new RelativePattern ( this . cwd , `{phpstan.neon,phpstan.neon.dist}` ) ,
203
+ new RelativePattern (
204
+ getWorkspacePath ( ) ,
205
+ `{phpstan.neon,phpstan.neon.dist}`
206
+ ) ,
201
207
( uri , eventName ) => {
202
208
if ( ! this . store . fileWatcher . enabled ) return ;
203
209
const path = sanitizeFsPath ( uri . fsPath ) ;
204
- this . log ( `[event:${ eventName } ] ${ path } ` ) ;
210
+ this . log ( {
211
+ tag : `event:${ eventName } ` ,
212
+ message : path ,
213
+ } ) ;
205
214
this . store . reactivate . timeout ( ( ) => this . reactivate ( ) ) ;
206
215
}
207
216
) ;
@@ -214,7 +223,10 @@ export class Ext<
214
223
for ( const patternPath of config . parameters ?. paths || [ ] ) {
215
224
const path = sanitizeFsPath ( uri . fsPath ) ;
216
225
if ( path . startsWith ( patternPath ) ) {
217
- this . log ( `[event:${ eventName } ] ${ path } ` ) ;
226
+ this . log ( {
227
+ tag : `event:${ eventName } ` ,
228
+ message : path ,
229
+ } ) ;
218
230
return await this . options . commands . analyse ( this ) ;
219
231
}
220
232
}
0 commit comments