mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 20:20:49 +00:00
Allow to configure loglevel through an env variable
This commit is contained in:
parent
6d2d943e18
commit
3573ef2bc5
3 changed files with 137 additions and 21 deletions
|
|
@ -7,14 +7,20 @@ export const LOGGING_NORMAL = "normal";
|
|||
export const LOGGING_VERBOSE = "verbose";
|
||||
|
||||
export function getLoggingLevel() {
|
||||
const level = cliArguments.getLoggingLevel();
|
||||
|
||||
if (level === LOGGING_SILENT) {
|
||||
return LOGGING_SILENT;
|
||||
// Priority 1: CLI argument
|
||||
const cliLevel = cliArguments.getLoggingLevel();
|
||||
if (cliLevel === LOGGING_SILENT || cliLevel === LOGGING_VERBOSE) {
|
||||
return cliLevel;
|
||||
}
|
||||
if (cliLevel) {
|
||||
// CLI arg was set but invalid, default to normal
|
||||
return LOGGING_NORMAL;
|
||||
}
|
||||
|
||||
if (level === LOGGING_VERBOSE) {
|
||||
return LOGGING_VERBOSE;
|
||||
// Priority 2: Environment variable
|
||||
const envLevel = environmentVariables.getLoggingLevel()?.toLowerCase();
|
||||
if (envLevel === LOGGING_SILENT || envLevel === LOGGING_VERBOSE) {
|
||||
return envLevel;
|
||||
}
|
||||
|
||||
return LOGGING_NORMAL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue