Skip to content

Commit

Permalink
ipc connection trace fix
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-marechal committed Oct 29, 2021
1 parent a8e930a commit 8d67a60
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/core/src/node/messaging/ipc-connection-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import * as cp from 'child_process';
import * as path from 'path';
import { injectable, inject } from 'inversify';
import { IPCMessageReader, IPCMessageWriter } from 'vscode-languageserver-protocol/node';
import { Trace, createMessageConnection, MessageConnection, Message } from 'vscode-languageserver-protocol';
import { Trace, createMessageConnection, MessageConnection, Message, Tracer } from 'vscode-languageserver-protocol';
import { ILogger, ConnectionErrorHandler, DisposableCollection, Disposable } from '../../common';
import { createIpcEnv } from './ipc-protocol';

Expand Down Expand Up @@ -84,12 +84,19 @@ export class IPCConnectionProvider {
info: (message: string) => this.logger.info(`[${options.serverName}: ${childProcess.pid}] ${message}`),
log: (message: string) => this.logger.info(`[${options.serverName}: ${childProcess.pid}] ${message}`)
});
const prefix = `[${options.serverName}: ${childProcess.pid}]`;
const tracer: Tracer = {
log: (message: unknown, data?: string) => {
this.logger.debug(typeof data === 'string'
? `${prefix} ${message} ${data}`
: `${prefix} ${message}`);
}
};
connection.trace(Trace.Verbose, tracer);
this.logger.isDebug().then(isDebug => {
const traceVerbosity = isDebug ? Trace.Verbose : Trace.Off;
connection.trace(traceVerbosity, {
log: (message: unknown, data?: string) => this.logger
.debug(`[${options.serverName}: ${childProcess.pid}] ${message}` + (typeof data === 'string' ? ' ' + data : ''))
});
if (!isDebug) {
connection.trace(Trace.Off, tracer);
}
});
return connection;
}
Expand Down

0 comments on commit 8d67a60

Please sign in to comment.