How to use the egg-logger.Transport function in egg-logger

To help you get started, we’ve selected a few egg-logger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eggjs / egg-mock / app / extend / application.js View on Github external
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 ]);
    });
  },

egg-logger

egg logger

MIT
Latest version published 22 days ago

Package Health Score

84 / 100
Full package analysis

Similar packages