mirror of
https://github.com/openstf/stf
synced 2025-10-05 19:42:01 +02:00
Add a timestamp to log output. Closes #730.
This commit is contained in:
parent
3b632b4314
commit
bac3b5e987
2 changed files with 17 additions and 15 deletions
|
@ -33,21 +33,21 @@ function Log(tag) {
|
|||
this.tag = tag
|
||||
this.names = {
|
||||
1: 'DBG'
|
||||
, 2: 'VRB'
|
||||
, 3: 'INF'
|
||||
, 4: 'IMP'
|
||||
, 5: 'WRN'
|
||||
, 6: 'ERR'
|
||||
, 7: 'FTL'
|
||||
, 2: 'VRB'
|
||||
, 3: 'INF'
|
||||
, 4: 'IMP'
|
||||
, 5: 'WRN'
|
||||
, 6: 'ERR'
|
||||
, 7: 'FTL'
|
||||
}
|
||||
this.styles = {
|
||||
1: 'grey'
|
||||
, 2: 'cyan'
|
||||
, 3: 'green'
|
||||
, 4: 'magenta'
|
||||
, 5: 'yellow'
|
||||
, 6: 'red'
|
||||
, 7: 'red'
|
||||
, 2: 'cyan'
|
||||
, 3: 'green'
|
||||
, 4: 'magenta'
|
||||
, 5: 'yellow'
|
||||
, 6: 'red'
|
||||
, 7: 'red'
|
||||
}
|
||||
this.localIdentifier = null
|
||||
events.EventEmitter.call(this)
|
||||
|
@ -107,7 +107,7 @@ Log.prototype.fatal = function() {
|
|||
|
||||
Log.prototype._entry = function(priority, args) {
|
||||
return new Log.Entry(
|
||||
Date.now()
|
||||
new Date()
|
||||
, priority
|
||||
, this.tag
|
||||
, process.pid
|
||||
|
@ -117,9 +117,10 @@ Log.prototype._entry = function(priority, args) {
|
|||
}
|
||||
|
||||
Log.prototype._format = function(entry) {
|
||||
return util.format('%s/%s %d [%s] %s'
|
||||
return util.format('%s %s/%s %d [%s] %s'
|
||||
, chalk.grey(entry.timestamp.toJSON())
|
||||
, this._name(entry.priority)
|
||||
, entry.tag
|
||||
, chalk.bold(entry.tag)
|
||||
, entry.pid
|
||||
, entry.identifier
|
||||
, entry.message
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue