Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mockLog(logger) {
logger = logger || this.logger;
if (typeof logger === 'string') {
logger = this.getLogger(logger);
}
// make sure mock once
if (logger._mockLogs) return;
const transport = new Transport(logger.options);
// https://github.com/eggjs/egg-logger/blob/master/lib/logger.js#L64
const log = logger.log;
mm(logger, '_mockLogs', []);
mm(logger, 'log', (level, args, meta) => {
const message = transport.log(level, args, meta);
logger._mockLogs.push(message);
log.apply(logger, [ level, args, meta ]);
});
},