From cfd13830483eef9940065611e58f6adacb8516a7 Mon Sep 17 00:00:00 2001 From: Alvaro Sanchez-Leon Date: Wed, 16 Jun 2021 16:49:59 -0400 Subject: [PATCH] Make IPC debug tracing configurable This change associates IPC tracing with the logger.debug method, therefore enabling debugging enables IPC tracing. Additionally, two new scripts are added to the top package.json to enable starting of the browser and electron application examples in debug mode. Signed-off-by: Alvaro Sanchez-Leon --- examples/electron/package.json | 2 +- package.json | 2 ++ packages/core/src/node/messaging/ipc-connection-provider.ts | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/electron/package.json b/examples/electron/package.json index e60f272977e61..7aef2cc128c1e 100644 --- a/examples/electron/package.json +++ b/examples/electron/package.json @@ -63,7 +63,7 @@ "bundle": "theia build --mode development", "watch": "concurrently -n compile,bundle \"theiaext watch --preserveWatchOutput\" \"theia build --watch --mode development\"", "start": "theia start --plugins=local-dir:../../plugins", - "start:debug": "yarn start --log-level=debug", + "start:debug": "yarn start --log-level=debug --remote-debugging-port=9222", "test": "electron-mocha --timeout 60000 \"./lib/test/**/*.espec.js\"" }, "devDependencies": { diff --git a/package.json b/package.json index 8ebecb2ab76ff..94a14b995e448 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,8 @@ "publish:check": "node scripts/check-publish.js", "start:browser": "yarn rebuild:browser && yarn --cwd examples/browser start", "start:electron": "yarn rebuild:electron && yarn --cwd examples/electron start", + "debug:browser": "yarn rebuild:browser && yarn --cwd examples/browser start:debug", + "debug:electron": "yarn rebuild:electron && yarn --cwd examples/electron start:debug", "download:plugins": "theia download:plugins" }, "workspaces": [ diff --git a/packages/core/src/node/messaging/ipc-connection-provider.ts b/packages/core/src/node/messaging/ipc-connection-provider.ts index 4ca773bc4675f..cdaa9048c0799 100644 --- a/packages/core/src/node/messaging/ipc-connection-provider.ts +++ b/packages/core/src/node/messaging/ipc-connection-provider.ts @@ -83,9 +83,10 @@ 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}`) }); - connection.trace(Trace.Off, { + const traceVerbosity = this.logger.isDebug() ? Trace.Verbose : Trace.Off; + connection.trace(traceVerbosity, { // eslint-disable-next-line @typescript-eslint/no-explicit-any - log: (message: any, data?: string) => this.logger.info(`[${options.serverName}: ${childProcess.pid}] ${message}` + (typeof data === 'string' ? ' ' + data : '')) + log: (message: any, data?: string) => this.logger.debug(`[${options.serverName}: ${childProcess.pid}] ${message}` + (typeof data === 'string' ? ' ' + data : '')) }); return connection; }