UNPKG

@contract-case/case-plugin-base

Version:

Plugin framework for writing plugins for the ContractCase test framework

39 lines 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.shouldLog = void 0; const errors_1 = require("../errors"); /** * Tests whether a given log level should log at this point in the execution * * DO NOT CALL THIS METHOD IN A PLUGIN * * @internal * * @param context - the current execution context * @param logLevel - the log level to test * @returns true if `logLevel` should be logged during this run */ const shouldLog = (context, logLevel) => { switch (context['_case:currentRun:context:logLevel']) { case 'none': return false; case 'error': return logLevel === 'error'; case 'warn': return (logLevel !== 'deepMaintainerDebug' && logLevel !== 'maintainerDebug' && logLevel !== 'debug'); case 'debug': return (logLevel !== 'maintainerDebug' && logLevel !== 'deepMaintainerDebug'); case 'maintainerDebug': return logLevel !== 'deepMaintainerDebug'; case 'deepMaintainerDebug': return true; case undefined: throw new errors_1.CaseCoreError(`The run context had no log level, but this should never happen. (context[_case:currentRun:context:logLevel] is ${context['_case:currentRun:context:logLevel']})`); default: throw new errors_1.CaseConfigurationError(`Unknown log level '${context['_case:currentRun:context:logLevel']}'`, context); } }; exports.shouldLog = shouldLog; //# sourceMappingURL=shouldLog.js.map