Skip to content

Commit

Permalink
[FEATURE] Add UI5_LOG_LVL environment variable
Browse files Browse the repository at this point in the history
To allow easy log level changes in scenarious where only single UI5 Tooling modules are being used
  • Loading branch information
RandomByte committed Nov 12, 2018
1 parent 3e3ae67 commit c3e65c4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/logger.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
const npmlog = require("npmlog");
npmlog.level = "info"; // Our default

if (process.env.UI5_LOG_LVL) {
const levels = ["silly", "verbose", "info", "warn", "error"];
const logLvl = process.env.UI5_LOG_LVL;
if (!levels.includes(logLvl)) {
throw new Error(`UI5 Logger: Environment variable UI5_LOG_LVL is set to an unkown log level "${logLvl}". ` +
`Valid levels are ${levels.join(", ")}`);
}
npmlog.level = logLvl;
} else {
npmlog.level = "info"; // Our default
}

npmlog.enableUnicode();

npmlog.on("error", (err) => {
Expand Down

0 comments on commit c3e65c4

Please sign in to comment.