mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Introduce silent mode to disable logging
This commit is contained in:
parent
2e1ee0dfa4
commit
9a78cafbfd
7 changed files with 142 additions and 4 deletions
|
|
@ -1,5 +1,6 @@
|
|||
const state = {
|
||||
malwareAction: undefined,
|
||||
loggingLevel: undefined,
|
||||
};
|
||||
|
||||
const SAFE_CHAIN_ARG_PREFIX = "--safe-chain-";
|
||||
|
|
@ -7,6 +8,7 @@ const SAFE_CHAIN_ARG_PREFIX = "--safe-chain-";
|
|||
export function initializeCliArguments(args) {
|
||||
// Reset state on each call
|
||||
state.malwareAction = undefined;
|
||||
state.loggingLevel = undefined;
|
||||
|
||||
const safeChainArgs = [];
|
||||
const remainingArgs = [];
|
||||
|
|
@ -20,6 +22,7 @@ export function initializeCliArguments(args) {
|
|||
}
|
||||
|
||||
setMalwareAction(safeChainArgs);
|
||||
setLoggingLevel(safeChainArgs);
|
||||
|
||||
return remainingArgs;
|
||||
}
|
||||
|
|
@ -48,3 +51,17 @@ function getLastArgEqualsValue(args, prefix) {
|
|||
export function getMalwareAction() {
|
||||
return state.malwareAction;
|
||||
}
|
||||
|
||||
function setLoggingLevel(args) {
|
||||
const safeChainLoggingArg = SAFE_CHAIN_ARG_PREFIX + "logging=";
|
||||
|
||||
const level = getLastArgEqualsValue(args, safeChainLoggingArg);
|
||||
if (!level) {
|
||||
return;
|
||||
}
|
||||
state.loggingLevel = level.toLowerCase();
|
||||
}
|
||||
|
||||
export function getLoggingLevel() {
|
||||
return state.loggingLevel;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue