Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 00b2906

Browse files
committed
Add handleServerStderr method, restore default stderr logging
Log per line of stderr
1 parent cc9e20d commit 00b2906

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lib/auto-languageclient.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export default class AutoLanguageClient {
232232
} finally {
233233
startingSignal && startingSignal.dispose();
234234
}
235-
235+
this.captureServerErrors(process, projectPath);
236236
const connection = new ls.LanguageClientConnection(this.createRpcConnection(process), this.logger);
237237
this.preInitialization(connection);
238238
const initializeParams = this.getInitializeParams(projectPath, process);
@@ -255,13 +255,13 @@ export default class AutoLanguageClient {
255255
return newServer;
256256
}
257257

258-
captureServerErrors(childProcess: child_process$ChildProcess): void {
258+
captureServerErrors(childProcess: child_process$ChildProcess, projectPath: string): void {
259259
childProcess.on('error', err => this.handleSpawnFailure(err));
260-
childProcess.on('exit', (code, signal) => this.logger.debug(`exited code ${code}`));
260+
childProcess.on('exit', (code, signal) => code !== null && this.logger.debug(`exit code: ${code}`));
261261
childProcess.stderr.setEncoding('utf8');
262262
childProcess.stderr.on('data', (chunk: Buffer) => {
263263
const errorString = chunk.toString();
264-
this.logger.warn('stderr', errorString);
264+
this.handleServerStderr(errorString, projectPath);
265265
// Keep the last 5 lines for packages to use in messages
266266
this.processStdErr = (this.processStdErr + errorString)
267267
.split('\n')
@@ -572,4 +572,12 @@ export default class AutoLanguageClient {
572572
filterChangeWatchedFiles(filePath: string): boolean {
573573
return true;
574574
}
575+
576+
/**
577+
* Called on language server stderr output.
578+
* @param stderr a chunk of stderr from a language server instance
579+
*/
580+
handleServerStderr(stderr: string, projectPath: string) {
581+
stderr.split('\n').filter(l => l).forEach(line => this.logger.warn(`stderr ${line}`));
582+
}
575583
}

0 commit comments

Comments
 (0)