1
1
"use strict" ;
2
2
var HipChatClient = require ( 'hipchat-client' ) ;
3
3
var layouts = require ( '../layouts' ) ;
4
- var layout ;
5
4
6
- var hipchat , config ;
5
+ exports . name = 'hipchat' ;
6
+ exports . appender = hipchatAppender ;
7
+ exports . configure = hipchatConfigure ;
7
8
8
9
//hipchat has more limited colors
9
10
var colours = {
@@ -17,9 +18,10 @@ var colours = {
17
18
OFF : "grey"
18
19
} ;
19
20
20
- function hipchatAppender ( _config , _layout ) {
21
+ function hipchatAppender ( config , layout ) {
21
22
22
- layout = _layout || layouts . basicLayout ;
23
+ var client = new HipChatClient ( _config . api_key ) ;
24
+ layout = layout || layouts . basicLayout ;
23
25
24
26
return function ( loggingEvent ) {
25
27
@@ -32,25 +34,18 @@ function hipchatAppender(_config, _layout) {
32
34
notify : _config . notify
33
35
} ;
34
36
35
- hipchat . api . rooms . message ( data , function ( err , res ) {
37
+ client . api . rooms . message ( data , function ( err , res ) {
36
38
if ( err ) {
37
39
throw err ;
38
40
}
39
41
} ) ;
40
- } ;
41
- }
42
-
43
- function configure ( _config ) {
44
-
45
- if ( _config . layout ) {
46
- layout = layouts . layout ( _config . layout . type , _config . layout ) ;
47
42
}
48
-
49
- hipchat = new HipChatClient ( _config . api_key ) ;
50
-
51
- return hipchatAppender ( _config , layout ) ;
52
43
}
53
44
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