Comparing version 1.2.0 to 1.2.2
@@ -30,3 +30,3 @@ /* | ||
term = term.toLowerCase(); | ||
if (term.indexOf('color') != -1) return true; | ||
if (term.indexOf('color') !== -1) return true; | ||
return term === 'xterm' || term === 'linux'; | ||
@@ -33,0 +33,0 @@ } |
@@ -25,3 +25,3 @@ /* | ||
return func(text); | ||
}; | ||
} | ||
@@ -35,6 +35,8 @@ | ||
'warn': 3, | ||
'error': 4 | ||
'error': 4, | ||
'silent': 5 | ||
} | ||
function Logging(level) { | ||
EventEmitter.call(this); | ||
this.level = level || 'info'; | ||
@@ -44,3 +46,3 @@ this.indent = 0; | ||
} | ||
Logging.prototype.__proto__ = EventEmitter.prototype; | ||
util.inherits(Logging, EventEmitter); | ||
@@ -60,6 +62,7 @@ Logging.prototype.log = function() { | ||
this.emit('logging-' + level); | ||
this.emit('logging-' + level, msg); | ||
if (!definedLevels.hasOwnProperty(this.level)) return; | ||
if (definedLevels[level] < definedLevels[this.level]) return; | ||
var text = Array(this.indent + 1).join(' '); | ||
var text = new Array(this.indent + 1).join(' '); | ||
var levelScheme = this.scheme[level] || {}; | ||
@@ -116,3 +119,3 @@ text += (levelScheme.start || ''); | ||
exports = module.exports = new Logging; | ||
exports = module.exports = new Logging(); | ||
exports.Logging = Logging |
{ | ||
"name": "colorful", | ||
"version": "1.2.0", | ||
"version": "1.2.2", | ||
"description": "colorful if a terminal tool for color, logging and command", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -1,2 +0,3 @@ | ||
var Logging = require('../lib/logging').Logging; | ||
var logging = require('../lib/logging'); | ||
var Logging = logging.Logging; | ||
var should = require('should'); | ||
@@ -29,3 +30,10 @@ | ||
}); | ||
it('should have event', function(done) { | ||
logging.on('logging-info', function(data) { | ||
data.should.equal('hello'); | ||
done(); | ||
}); | ||
logging.info('hello'); | ||
}); | ||
}); | ||
Sorry, the diff of this file is not supported yet
14631
337