UNPKG

express-user-agent-blocker

Version:

Express middleware for blocking access based on User Agent

19 lines (18 loc) 708 B
Object.defineProperty(exports, "__esModule", { value: true }); exports.getLogger = void 0; const debug_1 = require("debug"); /** * Get a logger for a particular namespace, or return a custom log function * @param {string} namespace - the namespace to log for * @param {Options} [options] - optional options which may contain custom log function * @returns {Log} the log function */ const getLogger = (namespace, options = { logger: undefined }) => { if (options.logger && options.logger.log instanceof Function) { return options.logger.log; } const logger = debug_1.default(namespace); logger.log = console.log.bind(console); return logger; }; exports.getLogger = getLogger;