Skip to content

Commit

Permalink
Add colours to http methods
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkie committed Sep 1, 2014
1 parent c0cec4f commit c692a54
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,14 @@ internals.Monitor.prototype._display = function (events) {
else if (event.event === 'request') {
var query = event.query ? JSON.stringify(event.query) : '';

var methodColors = { 'get': 32, 'delete': 31, 'put': 36, 'post': 33 };

var method = event.method;
if(event.method) {
var color = methodColors[method] || 34;
method = '\x1b[1;' + color + 'm' + event.method + '\x1b[0m';
}

var statusCode = event.statusCode;
if (event.statusCode) {
var color = (event.statusCode >= 500 ? 31 : (event.statusCode >= 400 ? 33 : (event.statusCode >= 300 ? 36 : 32)));
Expand Down

0 comments on commit c692a54

Please sign in to comment.