-
-
Save azat-co/67509d5c8e38d2f5f4dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sendHipChatMessage = function(message, callback) { | |
var fromhost = server | |
.set('hostname') | |
.replace('-','') | |
.substr(0, 15); //truncate the string | |
try { | |
message = JSON.stringify(message); | |
} catch(e) {} | |
var data = { | |
'format': 'json', | |
auth_token: server.config.keys.hipchat.servers, | |
room_id: server.config.keys.hipchat.serversRoomId, | |
from: fromhost, | |
message: 'v' | |
+ server.set('version') | |
+ '\nmessage: ' | |
+ message | |
}; | |
request({ | |
url:'http://api.hipchat.com/v1/rooms/message', | |
method:'POST', | |
qs: data}, function (e, r, body) { | |
if (e) console.error(e); | |
if (callback) return callback(); | |
}); | |
}; | |
server.notify = {}; | |
server.notify.error = function(e) { | |
var message = e.stack || e.message || e.name || e; | |
sendHipChatMessage(message); | |
console.error(message); | |
server.sendgrid.email({ | |
to: 'error@webapplog.com', | |
from: server.set('hostname') + '@webapplog.com', | |
subject: 'Webapp ' | |
+ server.set('version') | |
+ ' error: "' | |
+ e.name | |
+ '"', | |
category: 'webapp-error', | |
text: e.stack || e.message | |
}, exit); | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment