/* eslint-enable no-eval 
@function
@private

Get the configuration for the `pino` logger based
on the passed `laabr` options.

@param {Object} options The `laabr` plugin related options
@returns {Object} The overriden `pino` configs
359949
function getLoggerConfig (options) {
  return Object.assign(options.pino, {
    browser: {},
    timestamp: true,
    prettyPrint: true,
    prettifier: () => (data) => {
      const format = formats.get(data)
      const isJSON = utils.isJSON(format)
      const pictor = colors.get(data, isJSON || !options.colored)

      const preprocessed = validator('preformatterOutput', options.preformatter(data, options))
      const processed = compile(format, tokens, isJSON, options.indent, preprocessed, pictor)
      const postprocessed = validator('postformatterOutput', options.postformatter(processed, options))

      return `${postprocessed}\n`
    }
  })
}
428868
function
configure(options) {

  var config = {
    context: {},
    extension: '.html',
    verbose: false,
    renderString: false,
    piping: true
  };
  if (options === undefined || options === null)
    options = {};
  else
    options = cloneDeep(options);

  configureErrors(config, options);
  configureVerbosity(config, options);
  configureGlobals(config, options);
  configureLocals(config, options);
  configureContext(config, options);
  configureFiles(config, options);
  configureNunjucks(config, options);
  configurePluginOptions(config, options);

  return config;
}
447269
function Logger(opt) {
    var self = {};

    var defaultOptions = {
        name: 'gina', // by default
        template: '%d [ %s ] %m',
        //containers: [],
        levels : { // based on Sylog Severity Levels
            emerg: {
                code: 0,
                label: 'Emergency',
                desciption: 'System is unusable.',
                color: 'red'
            },
            alert: {
                code: 1,
                label: 'Alert',
                desciption: 'Action must be taken immediately.',
                color:'red'
            },

            crit: {
                code: 2,
                label: 'Critical',
                desciption: 'Critical conditions.',
                color: 'red'
            },
            error : {
                code: 3,
                label: 'Error',
                desciption: 'Error conditions.',
                color : 'orange'
            },
            warn : {
                code: 4,
                label: 'Warning',
                desciption: 'Warning conditions.',
                color: 'yellow'
            },
            notice: {
                code: 5,
                label: 'Notice',
                desciption: 'Normal but significant condition.',
                color: 'yellow'
            },
            info : {
                code: 6,
                label: 'Informational',
                desciption: 'Informational messages.',
                color: 'blue'
            },
            debug : {
                code: 7,
                label: 'Debug',
                desciption: 'Debug-level messages.',
                color: 'cyan'
                //'format' : '',
                //'pipe' : []
            }

        }
    };

    if (opt) {
        opt = merge(defaultOptions, opt, true)
    } else {
        opt = defaultOptions
    }

    /**
     * init
     * @constructor
     * */
    var init = function(opt) {
        if ( typeof(Logger.initialized) != "undefined" ) {
            console.debug("Logger instance already exists. Loading it.");
            return getInstance(opt)
        } else {
            Logger.initialized = true;
            Logger.instance = self;
            setDefaultLevels();
        }
    }

    var getInstance = function(opt) {
        return Logger.instance
    }

    var setDefaultLevels = function() {

        for (var l in opt.levels) {
            if ( typeof(self[l]) != 'undefined' )
                delete self[l];

            //self[l] = new Function('return '+write+'('+JSON.stringify(opt)+', '+parse+', "'+l+'", arguments);');
            self[l] = new Function('this._log_printed = false; process.stdout.write('+write+'('+JSON.stringify(opt)+', '+parse+', "'+l+'", arguments));');
        }
    }

    var write = function(opt, parse, s, args) {

        if ( /^(debugger listening on port)/.test(args[0])
            && typeof(opt.levels.info) != 'undefined'
        ) {
            s = 'info'
        }
        //process.stdout.write('\n'+ "LOGGER ACTION ? "+ s + ": ("+args.length+") ["+ args[0]+ "]");
        var content = '';
        //To handle logs with coma separated arguments.
        for (var i=0; i<args.length; ++i) {
            if (args[i] instanceof Function) {
                content += args[i].toString() + ''
            } else if (args[i] instanceof Object) {
                // careful, [ parse ] will be out of the main execution context: passing it for recursive use
                content += parse(parse, args[i], '')
            } else {
                //if ( args[i].replace(/\s/g, '') != '')
                //process.stdout.write('\n'+ ("=>> [" + args[i] + "]"));
                content += args[i] + ' '
            }
        }

        if (content != '' && !this._log_printed) {
            var now = new Date();
            var repl = {
                '%s': s, //severity
                '%d': now, // timestamp
                '%m': content // message
                //'%container', //container
            };

            var patt = opt.template.match(/\%[a-z A-Z 0-9]/g);
            content = opt.template;
            for(var p=0; p<patt.length; ++p) {
                content = content.replace(new RegExp(patt[p], 'g'), repl[patt[p]]);
            }

            //return process.stdout.write('\n'+ content)
            this._log_printed = true;
            return '\n'+ content
        }

        this._log_printed = false;
        return content
    }

    var parse = function(parse, obj, str) {
        var l = 0
            , len = obj.count()
            , isArray = (obj instanceof Array) ? true : false;
        str += (isArray) ? '[ ' : '{';

        for (var attr in obj) {
            ++l;
            if (obj[attr] instanceof Function) {
                str += attr +': [Function]';
                // if you want ot have it all replace by the fllowing line
                //str += attr +':'+ obj[attr].toString();
                str += (l<len) ? ', ' : ''
            } else if (obj[attr] instanceof Object && !isArray) {
                str += '"'+attr+'": ';
                str = parse(parse, obj[attr], str);
                str += (l<len) ? ', ' : '';
            } else {
                if (!isArray && typeof(obj[attr]) == 'string') {
                    str += '"'+attr+'": "' + obj[attr]
                            .replace(/\'/g, "\\'")
                            .replace(/\"/g, '\\"') +'"';
                } else if (isArray) {
                    str += ( typeof(obj[attr]) != 'string' ) ? obj[attr] : '"'+ obj[attr] +'"'
                } else {
                    str += '"'+attr+'": ' + obj[attr]
                }
                str += (l<len) ? ', ' : ''
            }
        }

        str += (isArray) ? ' ]' : '}';
        return str + ' '
    }

//    /**
//     * Add or override existing level(s)
//     * @param {object} levels
//     * */
//    this.addLevel = function(levels) {
//        for (var l in levels) {
//            self[l] = new Function('return '+write+'('+JSON.stringify(opt)+', "'+l+'", arguments);');
//        }
//    }

    self.setLevels = function(levels) {
        try {
            //remove default.
            for (var l in opt.levels) {
                delete self[l]
            }


            for (var l in levels) {
                self[l] = new Function('return '+write+'('+JSON.stringify(opt)+', '+parse+', "'+l+'", arguments);');
            }
        } catch(e) {
            setDefaultLevels();
            self.error('Cannot set type: ', e.stack|| e.message)
        }
    }

    self.getLogger = function(details) {
        console.debug('getting logger')
    }

    self.log = function() {
        var args = arguments, content = '';
        //console.log("arg: ", args);
        //To handle logs with coma speparated arguments.
        for (var i=0; i<args.length; ++i) {

            if (args[i] instanceof Object) {
                //console.log("\n...", args[i], args[i].toString());
                content += JSON.stringify(args[i], null, '\t')
            } else {
                content += args[i]
            }
        }
        //process.stdout.write('\n'+ "hum ? "+ content);
        //console.log("hum ? ", content);
        if (content != '')
            process.stdout.write('\n'+ content)
    }


    init(opt);
    return self
}
4294
function config(name, options) {
    if (isObject(name)) {
      extend(global, name);
      return;
    }
    var previous = (registry[name] && registry[name].$config) ? registry[name].$config() : null,
        base = extend({}, previous ? extend({}, previous) : extend({}, DEFAULTS, DEFAULT_METHODS));

    options = deepExtend(copy(base), options);

    if (!options.url) {
      options.url = global.base.replace(/\/$/, '') + '/' + hyphenate(name);
    }
    registry[name] = new ModelClass(options);
  }
548310
function HttpsConfig(options) {
    var httpsOptions = options && options.httpsOptions

    underscore.extend(this, HttpsConfig._DEFAULT)
    CommonConfig.call(this, options)
    this.httpsOptions = applyHttpsOptions.call(this, httpsOptions)
    this.type = serverTypes.HTTPS
}
1307998
function loggerCreator(logger, options) {
  // debug('loggerCreator', options);
  if (!logger || !logger.error || !logger.warn || !logger.info) {
    throw new Error('logger, logger.error, logger.warn and logger.info are required');
  }
  const pOptions = fp.clone(options || {});
  const getExtraReqHeaders = getHeaderFields(pOptions.headers || []);
  return function bunyanMiddleware(req, res, next) {
    // debug('bunyanMiddleware', req.url);
    // attach the logger to req
    req.logger = logger;
    const startTime = process.hrtime();
    const logs = Object.assign({}, getRequestId(req));
    req.logs = {};
    res.logs = {};
    function logging() {
      // debug('bunyanMiddleware', 'logging', logs.req_id);
      const resLog = Object.assign(
        {},
        logs,
        getStatusCode(res),
        getMethod(req),
        getUrls(req),
        getReqIp(req),
        getResTime(startTime),
        getReqHttpVersion(req),
        { req_headers: Object.assign(
          {}, getExtraReqHeaders(req), getBasicReqHeaders(req)) },
        getReqQuery(req),
        // getReqParams(req),
        getReqPath(req),
        getReqLogs(req),
        getResLogs(res)
      );

      const logLevel = defaultLevelFn(resLog.statusCode);
      const logFn = logger[logLevel];
      logFn.call(logger, resLog);
    }
    res.once('finish', logging);
    res.once('close', logging);
    next();
  };
}
944581
function handleLogger (config) {
  const configOptions = (config.logger || {}).options
  let Logger
  if (config.logger == null || config.logger.name === 'default') {
    Logger = DefaultLogger
  } else {
    Logger = resolvePluginClass(config.logger, 'logger')
  }

  if (configOptions instanceof Array) {
    // Note: This will not work on options without filename, and
    // is biased against for the winston logger
    let options
    for (let i = 0; i < configOptions.length; i++) {
      options = configOptions[i].options
      if (options && options.filename) {
        options.filename = fileUtils.lookupConfRequirePath(options.filename)
      }
    }
  }

  config.logger = new Logger(configOptions)
  if (!config.logger.info) {
    config.logger.debug = config.logger.log.bind(config.logger, C.LOG_LEVEL.DEBUG)
    config.logger.info = config.logger.log.bind(config.logger, C.LOG_LEVEL.INFO)
    config.logger.warn = config.logger.log.bind(config.logger, C.LOG_LEVEL.WARN)
    config.logger.error = config.logger.log.bind(config.logger, C.LOG_LEVEL.ERROR)
  }
  if (LOG_LEVEL_KEYS.indexOf(config.logLevel) !== -1) {
    // NOTE: config.logLevel has highest priority, compare to the level defined
    // in the nested logger object
    config.logLevel = C.LOG_LEVEL[config.logLevel]
    config.logger.setLogLevel(config.logLevel)
  }
}
266928
function argvPlugin(dynamicConfig, options) {
    var self = this;
    var separator;
    var whitelist;

    if (options && typeof options === "object") {
        separator = options.separator;
        whitelist = options.whitelist;
    }

    this(dynamicConfig).after("loadConfigFile", function (result) {
        self.override.result = merge(result, minimist(process.argv.slice(2)), separator, whitelist);
    });
}
347716
function PluginApiHelper(plugin) {
    this.plugin = plugin;

    /**
     * Public functions
     */

    // Return a properly formed API root of the specifed plugin.
    this.apiRoot = function() {
      return '/' + this.plugin.id;
    };

    // Return the user configuration of the plugin.
    this.getConfig = function(configId) {
      // If no configId specified then use 'default'.
      configId = configId || 'default';

      var config = {};
      var session = Session.getInstance();

      if (session.plugin.userConfig &&
        session.plugin.userConfig[this.plugin.id] &&
        session.plugin.userConfig[this.plugin.id][configId]) {

        config = session.plugin.userConfig[this.plugin.id][configId];
      }
      return config;
    };

    return this;
  }
984083
function applyLoggingOptions(config) {
  if (config.color === false) {
    logger.transports.console.colorize = false;
    reporterOutputLogger.transports.console.colorize = false;
  }

  // TODO https://github.com/apiaryio/dredd/issues/1346
  if (config.loglevel) {
    const loglevel = config.loglevel.toLowerCase();
    if (loglevel === 'silent') {
      logger.transports.console.silent = true;
    } else if (loglevel === 'warning') {
      logger.transports.console.level = 'warn';
    } else if (loglevel === 'debug') {
      logger.transports.console.level = 'debug';
      logger.transports.console.timestamp = true;
    } else if (['warn', 'error'].includes(loglevel)) {
      logger.transports.console.level = loglevel;
    } else {
      logger.transports.console.level = 'warn';
      throw new Error(`The logging level '${loglevel}' is unsupported, `
        + 'supported are: silent, error, warning, debug');
    }
  } else {
    logger.transports.console.level = 'warn';
  }
}
880455
function getContextPlugin(options) {
  var seneca = this;
  var plugin = 'get-context';

  seneca.wrap(options.pin, function (message, done) {
    var seneca = this;
    message.context$ = getContext(seneca);
    seneca.prior(message, done);
  });

  return {name: plugin};
}
394316
function getBaseConfig(isProd) {

  // get library details from JSON config
  var libraryDesc = require('./package.json').library;
  var libraryEntryPoint = path.join('src', libraryDesc.entry);

  // generate webpack base config
  return {
    entry: path.join(__dirname, libraryEntryPoint),
    output: {
      // ommitted - will be filled according to target env
    },
    module: {
      preLoaders: [
        {test: /\.js$/, exclude: /(node_modules|bower_components)/, loader: "eslint-loader"}
      ],
      loaders: [
        {test: /\.js$/, exclude: /(node_modules|bower_components)/, loader: "babel-loader"},
      ]
    },
    eslint: {
        configFile: './.eslintrc'
    },
    resolve: {
      root: path.resolve('./src'),
      extensions: ['', '.js']
    },
    devtool: isProd ? null : '#eval-source-map',
    debug: !isProd,
    plugins: isProd ? [
      new webpack.DefinePlugin({'process.env': {'NODE_ENV': '"production"'}}),
      new UglifyJsPlugin({ minimize: true })
      // Prod plugins here
    ] : [
      new webpack.DefinePlugin({'process.env': {'NODE_ENV': '"development"'}})
      // Dev plugins here
    ]
  };
}
1004512
function configureDefaults(options) {
  debug(options);
  options = options || {};
  options = options.reporterOptions || {};
  options.mochaFile = getSetting(options.mochaFile, 'MOCHA_FILE', 'test-results.xml');
  options.attachments = getSetting(options.attachments, 'ATTACHMENTS', false);
  options.antMode = getSetting(options.antMode, 'ANT_MODE', false);
  options.jenkinsMode = getSetting(options.jenkinsMode, 'JENKINS_MODE', false);
  options.properties = getSetting(options.properties, 'PROPERTIES', null, parsePropertiesFromEnv);
  options.toConsole = !!options.toConsole;
  options.rootSuiteTitle = options.rootSuiteTitle || 'Root Suite';
  options.testsuitesTitle = options.testsuitesTitle || 'Mocha Tests';

  if (options.antMode) {
    updateOptionsForAntMode(options);
  }

  if (options.jenkinsMode) {
    updateOptionsForJenkinsMode(options);
  }

  options.suiteTitleSeparedBy = options.suiteTitleSeparedBy || ' ';
  options.suiteTitleSeparatedBy = options.suiteTitleSeparatedBy || options.suiteTitleSeparedBy;

  return options;
}
49343
function LoggerConfiguration(logger) {
  /**
   * Override default logger instance with the provided logger
   * @public
   * @param {Object|Function} loggerOrFactoryFunction - the logger instance or factory function
   */
  function useLogger(loggerOrFactoryFunction) {
    cutil.assertObjectOrFunction(loggerOrFactoryFunction, 'loggerOrFactoryFunction');

    if (typeof(loggerOrFactoryFunction) === 'function') {
      logger = loggerOrFactoryFunction();
    }
    else {
      logger = loggerOrFactoryFunction;
    }
  };

  /**
   * Gets the default or overridden logger
   * @public
   */
  function getParams() {
    return { logger };
  }

  return {
    /**
     * Gets the target for a configurator function to run on
     * @public
     */
    getTarget: function() {
      return { useLogger: useLogger };
    },
    getParams: getParams
  };
}
1032653
function(pluginOptions) {
    if (!pluginOptions) {
        pluginOptions = {
            comments: false
        };
    }

    // Default options
    if (typeof pluginOptions.comments !== 'boolean') {
        pluginOptions.comments = false;
    }

    return map(function(file, cb) {
        var result = jsonlint(file.contents.toString('utf8'), pluginOptions);
        file.jsonlint = {
            error: result.error,
            line: result.line,
            character: result.character
        };

        // Pass file
        cb(null, file);
    });
}
1088917
function createLogger(name, options) {
        var log = typeof debug === 'undefined' ? _debug(name) : debug(name),
            level,
            levels = {
                silly: 0,
                input: 1,
                verbose: 2,
                prompt: 3,
                debug: 4,
                info: 5,
                data: 6,
                help: 7,
                warn: 8,
                error: 9
            };
        if (!options) {
            throw new Error('options required in logger');
        }
        if (options.hasOwnProperty('level') === false) {
            throw new Error('options.level required in logger');
        }
        level = levels[options.level];
        if (typeof level === 'undefined') {
            level = levels.info;
        }

        log.debug = function () {
            if (log.enabled && level <= levels.debug) {
                if (console.debug) {
                    log.log = console.debug.bind(console);
                } else {
                    log.log = console.log.bind(console);
                }
                log.apply(this, arguments);
            }
        };
        log.info = function () {
            if (log.enabled && level <= levels.info) {
                log.log = console.info.bind(console);
                log.apply(this, arguments);
            }
        };
        log.warn = function () {
            if (log.enabled && level <= levels.warn) {
                log.log = console.warn.bind(console);
                log.apply(this, arguments);
            }
        };
        log.error = function () {
            if (log.enabled && level <= levels.error) {
                log.log = console.error.bind(console);
                log.apply(this, arguments);
            } else {
                console.error.apply(console, arguments);
            }
        };

        log.fork = function (forkName, useForkName) {
            forkName = useForkName ? forkName : name + ':' + forkName;
            return createLogger(forkName, options);
        };

        log.forkWithOptions = function (_name, _options) {
            return createLogger(_name, _options);
        };

        return log;
    }
208674
function _getPrismOptions(options) {
    return {
        patterns,
        inheritenceMap,
        aliases,
        globalClass: options.globalClass,
        delay: !isNaN(options.delay) ? options.delay : 0
    };
}