1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 10:19:30 +02:00

Provider works more or less now.

This commit is contained in:
Simo Kinnunen 2014-01-07 20:09:39 +09:00
parent 789e608dab
commit 3f62a51d83
4 changed files with 132 additions and 15 deletions

View file

@ -1,15 +1,15 @@
var util = require('util')
var colors = require('colors')
function Log(tag, stream) {
this.tag = tag
this.stream = stream || process.stderr
this.levels = {
DEBUG: 'DBG'
, VERBOSE: 'VRB'
, INFO: 'INF'
, WARNING: 'WRN'
, ERROR: 'ERR'
, FATAL: 'FTL'
DEBUG: 'DBG'.grey
, VERBOSE: 'VRB'.cyan
, INFO: 'INF'.green
, WARNING: 'WRN'.yellow
, ERROR: 'ERR'.red
, FATAL: 'FTL'.red
}
}
@ -38,23 +38,24 @@ Log.prototype.fatal = function() {
}
Log.prototype._format = function(priority, args) {
return util.format('%s %s/%s %d %s\n',
Log.globalPrefix, priority, this.tag, process.pid,
return util.format('%s/%s %d [%s] %s',
priority, this.tag, process.pid, Log.globalIdentifier,
util.format.apply(util, args))
}
Log.prototype._write = function(out) {
this.stream.write(out)
console.error(out)
}
Log.globalPrefix = '*'
Log.globalIdentifier = '*'
Log.createLogger = function(tag) {
return new Log(tag)
}
Log.setGlobalPrefix = function(prefix) {
Log.globalPrefix = prefix
Log.setGlobalIdentifier = function(identifier) {
Log.globalIdentifier = identifier
return Log
}
exports = module.exports = Log