From e7d7ff3733a59c30ff2261461920f8dc2ef023fa Mon Sep 17 00:00:00 2001 From: Asher Date: Tue, 22 Jan 2019 13:11:54 -0600 Subject: [PATCH] Add some debug logging to the shared process --- packages/logger/src/logger.ts | 3 ++- packages/server/src/vscode/sharedProcess.ts | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/logger/src/logger.ts b/packages/logger/src/logger.ts index d5ff3ce1..77cecb9c 100644 --- a/packages/logger/src/logger.ts +++ b/packages/logger/src/logger.ts @@ -246,7 +246,7 @@ export class ServerFormatter extends Formatter { */ export class Logger { - public level = Level.Debug; + public level = Level.Info; private readonly nameColor?: string; private muted: boolean; @@ -335,6 +335,7 @@ export class Logger { */ public named(name: string, ...fields: FieldArray): Logger { const l = new Logger(this._formatter, name, fields); + l.level = this.level; if (this.muted) { l.mute(); } diff --git a/packages/server/src/vscode/sharedProcess.ts b/packages/server/src/vscode/sharedProcess.ts index 3421fd9b..19056842 100644 --- a/packages/server/src/vscode/sharedProcess.ts +++ b/packages/server/src/vscode/sharedProcess.ts @@ -20,20 +20,21 @@ export type SharedProcessEvent = { } | { readonly state: SharedProcessState.Stopped; readonly error: string; -} +}; export class SharedProcess { + public readonly socketPath: string = path.join(os.tmpdir(), `.vscode-online${Math.random().toString()}`); private _state: SharedProcessState = SharedProcessState.Stopped; private activeProcess: ChildProcess | undefined; private ipcHandler: StdioIpcHandler | undefined; private readonly onStateEmitter: Emitter; + private readonly logger = logger.named("SHDR PROC"); public constructor( private readonly userDataDir: string, ) { this.onStateEmitter = new Emitter(); - this.restart(); } @@ -100,7 +101,11 @@ export class SharedProcess { state: SharedProcessState.Ready, }); }); + this.activeProcess.stdout.on("data", (data) => { + this.logger.debug("stdout", field("message", data.toString())); + }); this.activeProcess.stderr.on("data", (data) => { + this.logger.debug("stderr", field("message", data.toString())); if (!resolved) { this.setState({ error: data.toString(), @@ -110,8 +115,6 @@ export class SharedProcess { return; } this.activeProcess.kill(); - } else { - logger.named("SHRD PROC").debug("stderr", field("message", data.toString())); } }); }