mirror of https://github.com/coder/code-server.git
Add some debug logging to the shared process
This commit is contained in:
parent
86c1c9993e
commit
e7d7ff3733
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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<SharedProcessEvent>;
|
||||
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()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue