Set shared process log level

This commit is contained in:
Asher 2019-02-07 13:50:17 -06:00
parent 86d70ec790
commit e4ff8e1c63
No known key found for this signature in database
GPG Key ID: 7BB4BA9C783D2BBC
2 changed files with 18 additions and 3 deletions

View File

@ -115,6 +115,8 @@ export class Entry extends Command {
next(); next();
}); });
// If we're not running from the binary and we aren't serving the static
// pre-built version, use webpack to serve the web files.
if (!isCli && !serveStatic) { if (!isCli && !serveStatic) {
const webpackConfig = require(path.join(__dirname, "..", "..", "web", "webpack.config.js")); const webpackConfig = require(path.join(__dirname, "..", "..", "web", "webpack.config.js"));
const compiler = require("webpack")(webpackConfig); const compiler = require("webpack")(webpackConfig);

View File

@ -80,17 +80,30 @@ 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: ParsedArgs; args: Partial<ParsedArgs>;
logLevel: LogLevel; logLevel: LogLevel;
} = { } = {
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,
} as any, },
logLevel: 0, logLevel,
sharedIPCHandle: this.socketPath, sharedIPCHandle: this.socketPath,
}; };
this.ipcHandler!.send("handshake:hey there", "", data); this.ipcHandler!.send("handshake:hey there", "", data);