Fix failure due to included files when using vscode's log level enum

This commit is contained in:
Asher 2019-02-07 14:17:14 -06:00
parent e4ff8e1c63
commit 73762017c8
No known key found for this signature in database
GPG Key ID: 7BB4BA9C783D2BBC
2 changed files with 10 additions and 22 deletions

View File

@ -2,10 +2,11 @@
* Log level. * Log level.
*/ */
export enum Level { export enum Level {
Debug = 0, Trace,
Info = 1, Debug,
Warn = 2, Info,
Error = 3, Warning,
Error,
} }
/** /**
@ -229,7 +230,7 @@ export class Logger {
switch (envLevel) { switch (envLevel) {
case "debug": this.level = Level.Debug; break; case "debug": this.level = Level.Debug; break;
case "info": this.level = Level.Info; break; case "info": this.level = Level.Info; break;
case "warn": this.level = Level.Warn; break; case "warn": this.level = Level.Warning; break;
case "error": this.level = Level.Error; break; case "error": this.level = Level.Error; break;
} }
} }
@ -272,7 +273,7 @@ export class Logger {
message, message,
fields, fields,
tagColor: "#FF9D00", tagColor: "#FF9D00",
level: Level.Warn, level: Level.Warning,
}); });
} }

View File

@ -5,9 +5,9 @@ import * as path from "path";
import { forkModule } from "./bootstrapFork"; import { forkModule } from "./bootstrapFork";
import { StdioIpcHandler } from "../ipc"; import { StdioIpcHandler } from "../ipc";
import { ParsedArgs } from "vs/platform/environment/common/environment"; import { ParsedArgs } from "vs/platform/environment/common/environment";
import { LogLevel } from "vs/platform/log/common/log";
import { Emitter } from "@coder/events/src"; import { Emitter } from "@coder/events/src";
import { retry } from "@coder/ide/src/retry"; import { retry } from "@coder/ide/src/retry";
import { logger, Level } from "@coder/logger";
export enum SharedProcessState { export enum SharedProcessState {
Stopped, Stopped,
@ -80,30 +80,17 @@ export class SharedProcess {
}); });
this.ipcHandler = new StdioIpcHandler(this.activeProcess); this.ipcHandler = new StdioIpcHandler(this.activeProcess);
this.ipcHandler.once("handshake:hello", () => { this.ipcHandler.once("handshake:hello", () => {
let logLevel = LogLevel.Warning;
const envLevel = typeof global !== "undefined" && typeof global.process !== "undefined" ? global.process.env.LOG_LEVEL : process.env.LOG_LEVEL;
if (envLevel) {
switch (envLevel) {
case "trace": logLevel = LogLevel.Trace; break;
case "debug": logLevel = LogLevel.Debug; break;
case "info": logLevel = LogLevel.Info; break;
case "warn": logLevel = LogLevel.Warning; break;
case "error": logLevel = LogLevel.Error; break;
case "critical": logLevel = LogLevel.Critical; break;
case "off": logLevel = LogLevel.Off; break;
}
}
const data: { const data: {
sharedIPCHandle: string; sharedIPCHandle: string;
args: Partial<ParsedArgs>; args: Partial<ParsedArgs>;
logLevel: LogLevel; logLevel: Level;
} = { } = {
args: { args: {
"builtin-extensions-dir": this.builtInExtensionsDir, "builtin-extensions-dir": this.builtInExtensionsDir,
"user-data-dir": this.userDataDir, "user-data-dir": this.userDataDir,
"extensions-dir": extensionsDir, "extensions-dir": extensionsDir,
}, },
logLevel, logLevel: logger.level,
sharedIPCHandle: this.socketPath, sharedIPCHandle: this.socketPath,
}; };
this.ipcHandler!.send("handshake:hey there", "", data); this.ipcHandler!.send("handshake:hey there", "", data);