mirror of
https://github.com/openstf/stf
synced 2025-10-03 17:59:28 +02:00
More control over logger colors.
This commit is contained in:
parent
315418d790
commit
6fc2791ab2
1 changed files with 19 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue