diff --git a/lib/util/logger.js b/lib/util/logger.js index 2a6ad7a5..57513fdf 100644 --- a/lib/util/logger.js +++ b/lib/util/logger.js @@ -4,12 +4,20 @@ var colors = require('colors') function Log(tag, stream) { this.tag = tag this.levels = { - DEBUG: 'DBG'.grey - , VERBOSE: 'VRB'.cyan - , INFO: 'INF'.green - , WARNING: 'WRN'.yellow - , ERROR: 'ERR'.red - , FATAL: 'FTL'.red + DEBUG: 'DBG' + , VERBOSE: 'VRB' + , INFO: 'INF' + , WARNING: 'WRN' + , ERROR: 'ERR' + , FATAL: 'FTL' + } + this.colors = { + DBG: 'grey' + , VRB: 'cyan' + , INF: 'green' + , WRN: 'yellow' + , ERR: 'red' + , FTL: 'red' } this.localIdentifier = null } @@ -42,9 +50,13 @@ Log.prototype.fatal = function() { this._write(this._format(this.levels.FATAL, arguments)) } +Log.prototype._color = function(priority) { + return priority[this.colors[priority]] +} + Log.prototype._format = function(priority, args) { return util.format('%s/%s %d [%s] %s' - , priority + , this._color(priority) , this.tag , process.pid , this.localIdentifier || Log.globalIdentifier