Sha256: da199c20fba74fea0733102e95124a785ff9e7405d2f3fc8a9c35fd46f9f30df

Contents?: true

Size: 1.48 KB

Versions: 48

Compression:

Stored size: 1.48 KB

Contents

/*
 * config.js: Default settings for all levels that winston knows about
 *
 * (C) 2010 Charlie Robbins
 * MIT LICENCE
 *
 */

var colors = require('colors/safe');

var config = exports,
    allColors = exports.allColors = {};

config.addColors = function (colors) {
  mixin(allColors, colors);
};

config.colorize = function (level, message) {
  if (typeof message === 'undefined') message = level;

  var colorized = message;
  if (allColors[level] instanceof Array) {
    for (var i = 0, l = allColors[level].length; i < l; ++i) {
      colorized = colors[allColors[level][i]](colorized);
    }
  } else if (allColors[level].match(/\s/)) {
    var colorArr = allColors[level].split(/\s+/);
    for (var i = 0; i < colorArr.length; ++i) {
      colorized = colors[colorArr[i]](colorized);
    }
    allColors[level] = colorArr;
  } else {
    colorized = colors[allColors[level]](colorized);
  }
  return colorized;
};

//
// Export config sets
//
config.cli    = require('./config/cli-config');
config.npm    = require('./config/npm-config');
config.syslog = require('./config/syslog-config');

//
// Add colors for pre-defined config sets
//
config.addColors(config.cli.colors);
config.addColors(config.npm.colors);
config.addColors(config.syslog.colors);

function mixin (target) {
  var args = Array.prototype.slice.call(arguments, 1);

  args.forEach(function (a) {
    var keys = Object.keys(a);
    for (var i = 0; i < keys.length; i++) {
      target[keys[i]] = a[keys[i]];
    }
  });
  return target;
};

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
passenger-6.0.12 src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js
passenger-6.0.11 src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js
passenger-6.0.10 src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js
passenger-6.0.9 src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js
passenger-6.0.8 src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js
passenger-6.0.7 src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js
passenger-6.0.6 src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js
passenger-6.0.5 src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js
passenger-6.0.4 src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js
passenger-6.0.3 src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js
passenger-6.0.2 src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js
passenger-6.0.1 src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js
passenger-6.0.0 src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js
passenger-5.3.7 src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js
passenger-5.3.6 src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js
passenger-5.3.5 src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js
passenger-5.3.4 src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js
passenger-5.3.3 src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js
passenger-5.3.2 src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js
passenger-5.3.1 src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js