8000 do not share state between hipchat appenders · wxqGitHub/log4js-node@b5a66af · GitHub
[go: up one dir, main page]

Skip to content

Commit b5a66af

Browse files
committed
do not share state between hipchat appenders
1 parent 1ab6219 commit b5a66af

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

lib/appenders/hipchat.js

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
"use strict";
22
var HipChatClient = require('hipchat-client');
33
var layouts = require('../layouts');
4-
var layout;
54

6-
var hipchat, config;
5+
exports.name = 'hipchat';
6+
exports.appender = hipchatAppender;
7+
exports.configure = hipchatConfigure;
78

89
//hipchat has more limited colors
910
var colours = {
@@ -17,9 +18,10 @@ var colours = {
1718
OFF: "grey"
1819
};
1920

20-
function hipchatAppender(_config, _layout) {
21+
function hipchatAppender(config, layout) {
2122

22-
layout = _layout || layouts.basicLayout;
23+
var client = new HipChatClient(_config.api_key);
24+
layout = layout || layouts.basicLayout;
2325

2426
return function(loggingEvent) {
2527

@@ -32,25 +34,18 @@ function hipchatAppender(_config, _layout) {
3234
notify: _config.notify
3335
};
3436

35-
hipchat.api.rooms.message(data, function(err, res) {
37+
client.api.rooms.message(data, function(err, res) {
3638
if (err) {
3739
throw err;
3840
}
3941
});
40-
};
41-
}
42-
43-
function configure(_config) {
44-
45-
if (_config.layout) {
46-
layout = layouts.layout(_config.layout.type, _config.layout);
4742
}
48-
49-
hipchat = new HipChatClient(_config.api_key);
50-
51-
return hipchatAppender(_config, layout);
5243
}
5344

54-
exports.name = 'hipchat';
55-
exports.appender = hipchatAppender;
56-
exports.configure = configure;
45+
function hipchatConfigure(config) {
46+
var layout;
47+
if (config.layout) {
48+
layout = layouts.layout(config.layout.type, config.layout);
49+
}
50+
return hipchatAppender(config, layout);
51+
}

0 commit comments

Comments
 (0)
0