3 var hipchat = require('hipchat-notifier');
4 var layouts = require('../layouts');
6 exports.name = 'hipchat';
7 exports.appender = hipchatAppender;
8 exports.configure = hipchatConfigure;
17 "hipchat_token": "< User token with Notification Privileges >",
18 "hipchat_room": "< Room ID or Name >",
20 "hipchat_from": "[ additional from label ]",
21 "hipchat_notify": "[ notify boolean to bug people ]",
22 "hipchat_host" : "api.hipchat.com"
27 var logger = log4js.getLogger("hipchat");
28 logger.warn("Test Warn message");
33 function hipchatNotifierResponseCallback(err, response, body){
39 function hipchatAppender(config) {
41 var notifier = hipchat.make(config.hipchat_room, config.hipchat_token);
43 // @lint W074 This function's cyclomatic complexity is too high. (10)
44 return function(loggingEvent){
48 notifier.setRoom(config.hipchat_room);
49 notifier.setFrom(config.hipchat_from || '');
50 notifier.setNotify(config.hipchat_notify || false);
52 if(config.hipchat_host) {
53 notifier.setHost(config.hipchat_host);
56 switch (loggingEvent.level.toString()) {
62 notifierFn = "warning";
66 notifierFn = "failure";
69 notifierFn = "success";
72 // @TODO, re-work in timezoneOffset ?
73 var layoutMessage = config.layout(loggingEvent);
75 // dispatch hipchat api request, do not return anything
76 // [overide hipchatNotifierResponseCallback]
77 notifier[notifierFn](layoutMessage, config.hipchat_response_callback ||
78 hipchatNotifierResponseCallback);
82 function hipchatConfigure(config) {
86 config.layout = layouts.messagePassThroughLayout;
89 return hipchatAppender(config, layout);