in apps/mountebank-mock/mountebank-source/src/cli/cli.js [317:358]
function parseLogConfiguration (args) {
// Not defaulted in yargs so we can test yargs value without defaulting interfering.
// This is needed for backwards compatibility with older CLI options.
const defaultConfig = {
level: 'info',
transports: {
console: {
colorize: true,
format: '%level: %message'
},
file: {
path: 'mb.log',
format: 'json'
}
}
};
if (typeof args.log === 'string') {
try {
args.log = JSON.parse(args.log);
}
catch (ex) {
console.error(`Cannot parse --log as JSON: ${ex}`);
args.log = defaultConfig;
}
}
else {
// Backwards compatibility with older CLI options. Using raw process.argv
// to ensure user actually passed the parameter, bypassing yargs defaulting
args.log = defaultConfig;
args.log.level = argvOrDefaultFor('loglevel');
args.log.transports.file.path = argvOrDefaultFor('logfile');
if (argIsPassedOnCLI('nologfile')) {
delete args.log.transports.file;
}
}
// Remove the old values to not confuse users retrieving configuration later
delete args.loglevel;
delete args.logfile;
delete args.nologfile;
}