logger.js 625 Bytes

/**
 * 日志工具类
 * @author: hbomb<qiqi.zhou@yoho.cn>
 * @date: 2016/05/06
 */
  'use strict';

  let winston = require('winston'),
      config = require('../config/common'),
      FileTransport = require('winston-daily-rotate-file');

  require('influxdb-winston');

  let logger = new (winston.Logger)({
      transports: [
          new (FileTransport)(config.loggers.infoFile),
          new (FileTransport)(config.loggers.errorFile),
          new (winston.transports.UdpTransport)(config.loggers.udp),
          new (winston.transports.Console)(config.loggers.console)
      ]
  });

  module.exports = logger;