diff --git a/packages/logger/src/logger.ts b/packages/logger/src/logger.ts index 77cecb9cc..0113ab3d3 100644 --- a/packages/logger/src/logger.ts +++ b/packages/logger/src/logger.ts @@ -260,6 +260,15 @@ export class Logger { if (name) { this.nameColor = hashStringToColor(name); } + this.info(`Log level: ${process.env.LOG_LEVEL || "info"}`); + if (process.env.LOG_LEVEL) { + switch (process.env.LOG_LEVEL) { + case "debug": this.level = Level.Debug; break; + case "info": this.level = Level.Info; break; + case "warn": this.level = Level.Warn; break; + case "error": this.level = Level.Error; break; + } + } } public set formatter(formatter: Formatter) { @@ -335,7 +344,6 @@ 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/cli.ts b/packages/server/src/cli.ts index 9df18f8ee..a77e8d7d9 100644 --- a/packages/server/src/cli.ts +++ b/packages/server/src/cli.ts @@ -20,7 +20,6 @@ export class Entry extends Command { host: flags.string({ char: "h", default: "0.0.0.0" }), open: flags.boolean({ char: "o", description: "Open in browser on startup" }), port: flags.integer({ char: "p", default: 8080, description: "Port to bind on" }), - logLevel: flags.enum({ char: "l", options: [ "debug", "info", "warn", "error" ]}), version: flags.version({ char: "v" }), // Dev flags @@ -51,15 +50,6 @@ export class Entry extends Command { const { args, flags } = this.parse(Entry); - if (flags.logLevel) { - switch (flags.logLevel) { - case "debug": logger.level = Level.Debug; break; - case "info": logger.level = Level.Info; break; - case "warn": logger.level = Level.Warn; break; - case "error": logger.level = Level.Error; break; - } - } - if (flags["bootstrap-fork"]) { const modulePath = flags["bootstrap-fork"]; if (!modulePath) { diff --git a/scripts/webpack.general.config.js b/scripts/webpack.general.config.js index e29226d52..8b99ca74c 100644 --- a/scripts/webpack.general.config.js +++ b/scripts/webpack.general.config.js @@ -86,6 +86,7 @@ module.exports = (options = {}) => ({ }), new webpack.DefinePlugin({ "process.env.NODE_ENV": `"${environment}"`, + "process.env.LOG_LEVEL": `"${process.env.LOG_LEVEL || ""}"`, }), new MiniCssExtractPlugin({ filename: "[name].css",