Skip to content

Commit

Permalink
Fix console plugin
Browse files Browse the repository at this point in the history
Was displaying 'NaN' messages since CheckEvent syntax was changed
  • Loading branch information
fzaninotto committed Sep 19, 2012
1 parent 76950ee commit e13a627
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions plugins/console/index.js
Expand Up @@ -11,9 +11,32 @@ exports.init = function(enableNewEvents, enableNewPings) {
var registerNewEventsLogger = function() {
CheckEvent.on('afterInsert', function(checkEvent) {
checkEvent.findCheck(function(err, check) {
var messageColor;
var message = check.name + ' ';
message += (checkEvent.isGoDown) ? 'goes down' : ('goes back up after ' + Math.floor(checkEvent.downtime / 1000) + 's of downtime');
console.log(timestamp() + color(message, checkEvent.isGoDown ? 'red+bold' : 'green+bold'));
switch (checkEvent.message) {
case 'paused':
case 'restarted':
message += 'was ' + checkEvent.message;
messageColor = 'blue+bold';
break;
case 'down':
message += 'went down ' + checkEvent.details;
messageColor = 'red+bold';
break;
case 'up':
if (checkEvent.downtime) {
message += 'went back up after ' + Math.floor(checkEvent.downtime / 1000) + 's of downtime';
} else {
message += 'is now up';
}
messageColor = 'green+bold';
break;
default:
message += '(unnown event)';
messageColor = 'bold';
}

console.log(timestamp() + color(message, messageColor));
});
});
};
Expand Down

0 comments on commit e13a627

Please sign in to comment.