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>'
|
||||
, 'minimum log level'
|
||||
, Number
|
||||
, logger.Level.IMPORTANT)
|
||||
.option('-n, --notify-priority <level>'
|
||||
, 'minimum log level to cause a notification'
|
||||
, Number
|
||||
, logger.Level.WARNING)
|
||||
.option('-s, --connect-sub <endpoint>'
|
||||
, 'sub endpoint'
|
||||
|
@ -373,6 +377,7 @@ program
|
|||
token: options.token
|
||||
, room: options.room
|
||||
, priority: options.priority
|
||||
, notifyPriority: options.notifyPriority
|
||||
, endpoints: {
|
||||
sub: options.connectSub
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ module.exports = syrup.serial()
|
|||
.catch(grouputil.NoGroupError, function() {
|
||||
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)
|
||||
|
||||
channels.register(currentGroup.group, timeout || options.groupTimeout)
|
||||
|
@ -64,7 +64,7 @@ module.exports = syrup.serial()
|
|||
plugin.leave = function() {
|
||||
return plugin.get()
|
||||
.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)
|
||||
|
||||
channels.unregister(group.group)
|
||||
|
|
|
@ -10,6 +10,16 @@ var wirerouter = require('../../wire/router')
|
|||
var wireutil = require('../../wire/util')
|
||||
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) {
|
||||
var log = logger.createLogger('notify-hipchat')
|
||||
var client = Promise.promisifyAll(new Hipchatter(options.token))
|
||||
|
@ -40,8 +50,9 @@ module.exports = function(options) {
|
|||
.handler())
|
||||
|
||||
function push() {
|
||||
var messages = buffer.splice(0).map(function(entry) {
|
||||
return util.format(
|
||||
buffer.splice(0).forEach(function(entry) {
|
||||
client.notifyAsync(options.room, {
|
||||
message: util.format(
|
||||
'<strong>%s</strong>/<strong>%s</strong> %d [<strong>%s</strong>] %s'
|
||||
, logger.LevelLabel[entry.priority]
|
||||
, entry.tag
|
||||
|
@ -49,17 +60,12 @@ module.exports = function(options) {
|
|||
, entry.identifier
|
||||
, entry.message
|
||||
)
|
||||
})
|
||||
|
||||
log.info('Sending %d message(s)', messages.length)
|
||||
|
||||
return client.notifyAsync(options.room, {
|
||||
message: messages.join('<br>')
|
||||
, color: 'purple'
|
||||
, notify: true
|
||||
, color: COLORS[entry.priority]
|
||||
, notify: entry.priority >= options.notifyPriority
|
||||
, 'message_format': 'html'
|
||||
, token: options.token
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
log.info('Listening for %s (or higher) level log messages',
|
||||
|
|
|
@ -9,18 +9,21 @@ Logger.Level = {
|
|||
DEBUG: 1
|
||||
, VERBOSE: 2
|
||||
, INFO: 3
|
||||
, WARNING: 4
|
||||
, ERROR: 5
|
||||
, FATAL: 6
|
||||
, IMPORTANT: 4
|
||||
, WARNING: 5
|
||||
, ERROR: 6
|
||||
, FATAL: 7
|
||||
}
|
||||
|
||||
// Exposed for other modules
|
||||
Logger.LevelLabel = {
|
||||
1: 'DBG'
|
||||
, 2: 'VRB'
|
||||
, 3: 'INF'
|
||||
, 4: 'WRN'
|
||||
, 5: 'ERR'
|
||||
, 6: 'FTL'
|
||||
, 4: 'IMP'
|
||||
, 5: 'WRN'
|
||||
, 6: 'ERR'
|
||||
, 7: 'FTL'
|
||||
}
|
||||
|
||||
Logger.globalIdentifier = '*'
|
||||
|
@ -40,17 +43,19 @@ function Log(tag) {
|
|||
1: 'DBG'
|
||||
, 2: 'VRB'
|
||||
, 3: 'INF'
|
||||
, 4: 'WRN'
|
||||
, 5: 'ERR'
|
||||
, 6: 'FTL'
|
||||
, 4: 'IMP'
|
||||
, 5: 'WRN'
|
||||
, 6: 'ERR'
|
||||
, 7: 'FTL'
|
||||
}
|
||||
this.styles = {
|
||||
1: 'grey'
|
||||
, 2: 'cyan'
|
||||
, 3: 'green'
|
||||
, 4: 'yellow'
|
||||
, 5: 'red'
|
||||
, 4: 'magenta'
|
||||
, 5: 'yellow'
|
||||
, 6: 'red'
|
||||
, 7: 'red'
|
||||
}
|
||||
this.localIdentifier = null
|
||||
events.EventEmitter.call(this)
|
||||
|
@ -83,6 +88,10 @@ Log.prototype.info = function() {
|
|||
this._write(this._entry(Logger.Level.INFO, arguments))
|
||||
}
|
||||
|
||||
Log.prototype.important = function() {
|
||||
this._write(this._entry(Logger.Level.IMPORTANT, arguments))
|
||||
}
|
||||
|
||||
Log.prototype.warn = function() {
|
||||
this._write(this._entry(Logger.Level.WARNING, arguments))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue