Skip to content

Commit

Permalink
Make IPC debug tracing configurable
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
alvsan09 committed Jun 18, 2021
1 parent 55b55ee commit cfd1383
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/node/messaging/ipc-connection-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit cfd1383

Please sign in to comment.