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

Add handleServerStderr method + default logging #158

Merged
merged 3 commits into from
Dec 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions lib/auto-languageclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export default class AutoLanguageClient {
} finally {
startingSignal && startingSignal.dispose();
}

this.captureServerErrors(process, projectPath);
const connection = new ls.LanguageClientConnection(this.createRpcConnection(process), this.logger);
this.preInitialization(connection);
const initializeParams = this.getInitializeParams(projectPath, process);
Expand All @@ -255,13 +255,13 @@ export default class AutoLanguageClient {
return newServer;
}

captureServerErrors(childProcess: child_process$ChildProcess): void {
captureServerErrors(childProcess: child_process$ChildProcess, projectPath: string): void {
childProcess.on('error', err => this.handleSpawnFailure(err));
childProcess.on('exit', (code, signal) => this.logger.debug(`exited code ${code} signal ${signal}`));
childProcess.on('exit', (code, signal) => this.logger.debug(`exit: code ${code} signal ${signal}`));
childProcess.stderr.setEncoding('utf8');
childProcess.stderr.on('data', (chunk: Buffer) => {
const errorString = chunk.toString();
this.logger.warn('stderr', errorString);
this.handleServerStderr(errorString, projectPath);
// Keep the last 5 lines for packages to use in messages
this.processStdErr = (this.processStdErr + errorString)
.split('\n')
Expand Down Expand Up @@ -575,4 +575,12 @@ export default class AutoLanguageClient {
filterChangeWatchedFiles(filePath: string): boolean {
return true;
}

/**
* Called on language server stderr output.
* @param stderr a chunk of stderr from a language server instance
*/
handleServerStderr(stderr: string, projectPath: string) {
stderr.split('\n').filter(l => l).forEach(line => this.logger.warn(`stderr ${line}`));
}
}