Skip to content

Commit

Permalink
fix: log stderr output to output channel
Browse files Browse the repository at this point in the history
e.g. stack traces from crashes
  • Loading branch information
felixfbecker committed Nov 11, 2018
1 parent aeab920 commit ba3c42d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
return;
}

let client: LanguageClient;

const serverOptions = () => new Promise<ChildProcess | StreamInfo>((resolve, reject) => {
// Use a TCP socket because of problems with blocking STDIO
const server = net.createServer(socket => {
Expand All @@ -81,10 +83,18 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
'--memory-limit=' + memoryLimit
]);
childProcess.stderr.on('data', (chunk: Buffer) => {
console.error(chunk + '');
const str = chunk.toString();
console.log('PHP Language Server:', str);
client.outputChannel.appendLine(str);
});
childProcess.stdout.on('data', (chunk: Buffer) => {
console.log(chunk + '');
// childProcess.stdout.on('data', (chunk: Buffer) => {
// console.log('PHP Language Server:', chunk + '');
// });
childProcess.on('exit', (code, signal) => {
client.outputChannel.appendLine(`Language server exited ` + (signal ? `from signal ${signal}` : `with exit code ${code}`));
if (code !== 0) {
client.outputChannel.show();
}
});
return childProcess;
});
Expand Down Expand Up @@ -112,7 +122,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
};

// Create the language client and start the client.
const disposable = new LanguageClient('PHP Language Server', serverOptions, clientOptions).start();
client = new LanguageClient('PHP Language Server', serverOptions, clientOptions);
const disposable = client.start();

// Push the disposable to the context's subscriptions so that the
// client can be deactivated on extension deactivation
Expand Down

0 comments on commit ba3c42d

Please sign in to comment.