mirror of
https://github.com/openstf/stf
synced 2025-10-04 10:19:30 +02:00
Add a new log priority: important. Should make it easier to display interesting non-error messages.
This commit is contained in:
parent
1095c1ba97
commit
97c4d24a7a
4 changed files with 52 additions and 32 deletions
|
@ -354,6 +354,10 @@ program
|
||||||
.option('-p, --priority <level>'
|
.option('-p, --priority <level>'
|
||||||
, 'minimum log level'
|
, 'minimum log level'
|
||||||
, Number
|
, Number
|
||||||
|
, logger.Level.IMPORTANT)
|
||||||
|
.option('-n, --notify-priority <level>'
|
||||||
|
, 'minimum log level to cause a notification'
|
||||||
|
, Number
|
||||||
, logger.Level.WARNING)
|
, logger.Level.WARNING)
|
||||||
.option('-s, --connect-sub <endpoint>'
|
.option('-s, --connect-sub <endpoint>'
|
||||||
, 'sub endpoint'
|
, 'sub endpoint'
|
||||||
|
@ -373,6 +377,7 @@ program
|
||||||
token: options.token
|
token: options.token
|
||||||
, room: options.room
|
, room: options.room
|
||||||
, priority: options.priority
|
, priority: options.priority
|
||||||
|
, notifyPriority: options.notifyPriority
|
||||||
, endpoints: {
|
, endpoints: {
|
||||||
sub: options.connectSub
|
sub: options.connectSub
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ module.exports = syrup.serial()
|
||||||
.catch(grouputil.NoGroupError, function() {
|
.catch(grouputil.NoGroupError, function() {
|
||||||
currentGroup = newGroup
|
currentGroup = newGroup
|
||||||
|
|
||||||
log.info('Now owned by "%s"', currentGroup.email)
|
log.important('Now owned by "%s"', currentGroup.email)
|
||||||
log.info('Subscribing to group channel "%s"', currentGroup.group)
|
log.info('Subscribing to group channel "%s"', currentGroup.group)
|
||||||
|
|
||||||
channels.register(currentGroup.group, timeout || options.groupTimeout)
|
channels.register(currentGroup.group, timeout || options.groupTimeout)
|
||||||
|
@ -64,7 +64,7 @@ module.exports = syrup.serial()
|
||||||
plugin.leave = function() {
|
plugin.leave = function() {
|
||||||
return plugin.get()
|
return plugin.get()
|
||||||
.then(function(group) {
|
.then(function(group) {
|
||||||
log.info('No longer owned by "%s"', group.email)
|
log.important('No longer owned by "%s"', group.email)
|
||||||
log.info('Unsubscribing from group channel "%s"', group.group)
|
log.info('Unsubscribing from group channel "%s"', group.group)
|
||||||
|
|
||||||
channels.unregister(group.group)
|
channels.unregister(group.group)
|
||||||
|
|
|
@ -10,6 +10,16 @@ var wirerouter = require('../../wire/router')
|
||||||
var wireutil = require('../../wire/util')
|
var wireutil = require('../../wire/util')
|
||||||
var lifecycle = require('../../util/lifecycle')
|
var lifecycle = require('../../util/lifecycle')
|
||||||
|
|
||||||
|
var COLORS = {
|
||||||
|
1: 'gray'
|
||||||
|
, 2: 'gray'
|
||||||
|
, 3: 'green'
|
||||||
|
, 4: 'purple'
|
||||||
|
, 5: 'yellow'
|
||||||
|
, 6: 'red'
|
||||||
|
, 7: 'red'
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = function(options) {
|
module.exports = function(options) {
|
||||||
var log = logger.createLogger('notify-hipchat')
|
var log = logger.createLogger('notify-hipchat')
|
||||||
var client = Promise.promisifyAll(new Hipchatter(options.token))
|
var client = Promise.promisifyAll(new Hipchatter(options.token))
|
||||||
|
@ -40,25 +50,21 @@ module.exports = function(options) {
|
||||||
.handler())
|
.handler())
|
||||||
|
|
||||||
function push() {
|
function push() {
|
||||||
var messages = buffer.splice(0).map(function(entry) {
|
buffer.splice(0).forEach(function(entry) {
|
||||||
return util.format(
|
client.notifyAsync(options.room, {
|
||||||
'<strong>%s</strong>/<strong>%s</strong> %d [<strong>%s</strong>] %s'
|
message: util.format(
|
||||||
, logger.LevelLabel[entry.priority]
|
'<strong>%s</strong>/<strong>%s</strong> %d [<strong>%s</strong>] %s'
|
||||||
, entry.tag
|
, logger.LevelLabel[entry.priority]
|
||||||
, entry.pid
|
, entry.tag
|
||||||
, entry.identifier
|
, entry.pid
|
||||||
, entry.message
|
, entry.identifier
|
||||||
)
|
, entry.message
|
||||||
})
|
)
|
||||||
|
, color: COLORS[entry.priority]
|
||||||
log.info('Sending %d message(s)', messages.length)
|
, notify: entry.priority >= options.notifyPriority
|
||||||
|
, 'message_format': 'html'
|
||||||
return client.notifyAsync(options.room, {
|
, token: options.token
|
||||||
message: messages.join('<br>')
|
})
|
||||||
, color: 'purple'
|
|
||||||
, notify: true
|
|
||||||
, 'message_format': 'html'
|
|
||||||
, token: options.token
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,18 +9,21 @@ Logger.Level = {
|
||||||
DEBUG: 1
|
DEBUG: 1
|
||||||
, VERBOSE: 2
|
, VERBOSE: 2
|
||||||
, INFO: 3
|
, INFO: 3
|
||||||
, WARNING: 4
|
, IMPORTANT: 4
|
||||||
, ERROR: 5
|
, WARNING: 5
|
||||||
, FATAL: 6
|
, ERROR: 6
|
||||||
|
, FATAL: 7
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Exposed for other modules
|
||||||
Logger.LevelLabel = {
|
Logger.LevelLabel = {
|
||||||
1: 'DBG'
|
1: 'DBG'
|
||||||
, 2: 'VRB'
|
, 2: 'VRB'
|
||||||
, 3: 'INF'
|
, 3: 'INF'
|
||||||
, 4: 'WRN'
|
, 4: 'IMP'
|
||||||
, 5: 'ERR'
|
, 5: 'WRN'
|
||||||
, 6: 'FTL'
|
, 6: 'ERR'
|
||||||
|
, 7: 'FTL'
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.globalIdentifier = '*'
|
Logger.globalIdentifier = '*'
|
||||||
|
@ -40,17 +43,19 @@ function Log(tag) {
|
||||||
1: 'DBG'
|
1: 'DBG'
|
||||||
, 2: 'VRB'
|
, 2: 'VRB'
|
||||||
, 3: 'INF'
|
, 3: 'INF'
|
||||||
, 4: 'WRN'
|
, 4: 'IMP'
|
||||||
, 5: 'ERR'
|
, 5: 'WRN'
|
||||||
, 6: 'FTL'
|
, 6: 'ERR'
|
||||||
|
, 7: 'FTL'
|
||||||
}
|
}
|
||||||
this.styles = {
|
this.styles = {
|
||||||
1: 'grey'
|
1: 'grey'
|
||||||
, 2: 'cyan'
|
, 2: 'cyan'
|
||||||
, 3: 'green'
|
, 3: 'green'
|
||||||
, 4: 'yellow'
|
, 4: 'magenta'
|
||||||
, 5: 'red'
|
, 5: 'yellow'
|
||||||
, 6: 'red'
|
, 6: 'red'
|
||||||
|
, 7: 'red'
|
||||||
}
|
}
|
||||||
this.localIdentifier = null
|
this.localIdentifier = null
|
||||||
events.EventEmitter.call(this)
|
events.EventEmitter.call(this)
|
||||||
|
@ -83,6 +88,10 @@ Log.prototype.info = function() {
|
||||||
this._write(this._entry(Logger.Level.INFO, arguments))
|
this._write(this._entry(Logger.Level.INFO, arguments))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.prototype.important = function() {
|
||||||
|
this._write(this._entry(Logger.Level.IMPORTANT, arguments))
|
||||||
|
}
|
||||||
|
|
||||||
Log.prototype.warn = function() {
|
Log.prototype.warn = function() {
|
||||||
this._write(this._entry(Logger.Level.WARNING, arguments))
|
this._write(this._entry(Logger.Level.WARNING, arguments))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue