コード例 #1
0
winston.setLevels = function (levels) {
  utils.setLevels(winston, defaultLogger.levels, levels);
  defaultLogger.setLevels(levels);
};
コード例 #2
0
winston.hash           = utils.hash;
winston.clone          = utils.clone;
winston.longestElement = utils.longestElement;
winston.config         = require('winston/config');
winston.addColors      = winston.config.addColors; 
winston.Logger         = require('winston/logger').Logger;

//
// We create and expose a "defaultLogger" so that the programmer may do the
// following without the need to create an instance of winston.Logger directly:
//   var winston = require('winston');
//   winston.log('info', 'some message');
//   winston.error('some error'); 
//
var defaultLogger = new (winston.Logger)({ transports: [new (winston.transports.Console)()] });
utils.setLevels(winston, null, defaultLogger.levels);

['log', 'add', 'remove', 'profile', 'extend'].forEach(function (method) {
  winston[method] = function () {
    return defaultLogger[method].apply(defaultLogger, arguments);
  };
});

winston.setLevels = function (levels) {
  utils.setLevels(winston, defaultLogger.levels, levels);
  defaultLogger.setLevels(levels);
};

//
// Define emitErrs property for default logger
//