Introduce silent mode to disable logging

This commit is contained in:
Sander Declerck 2025-10-23 17:45:03 +02:00
parent 2e1ee0dfa4
commit 9a78cafbfd
No known key found for this signature in database
7 changed files with 142 additions and 4 deletions

View file

@ -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;
}