fluent-plugin-hipchat 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +2 -0
- data/VERSION +1 -1
- data/lib/fluent/plugin/out_hipchat.rb +8 -4
- data/test/plugin/out_hipchat.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e1eaf019c429076398ea4723cfeb6c5d6db6dc5
|
4
|
+
data.tar.gz: 7cfe131f2ebb925e8d5de5787114301c9c0e37f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9198b96a460c242756c0d6f324f6e2b52e2c1e1aedfb843ed78e3f357f7196eff45bdf671813cfa1d44145149b66ce93ef66ba4da3efced2ec77e4aca0d714a7
|
7
|
+
data.tar.gz: 6e47b1a66401e702ee17bc76541229a3dc485cb4da56e172dcbe27c37edac9d5ea4dcc23d4026abb72dffd189fbb8b0163295fb82a8ecf7fbfef54b1ba58f496
|
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
@@ -11,6 +11,8 @@ module Fluent
|
|
11
11
|
config_param :default_from, :string, :default => nil
|
12
12
|
config_param :default_notify, :bool, :default => nil
|
13
13
|
config_param :default_format, :string, :default => nil
|
14
|
+
config_param :key_name, :string, :default => 'message'
|
15
|
+
config_param :default_timeout, :time, :default => nil
|
14
16
|
config_param :http_proxy_host, :string, :default => nil
|
15
17
|
config_param :http_proxy_port, :integer, :default => nil
|
16
18
|
config_param :http_proxy_user, :string, :default => nil
|
@@ -33,6 +35,7 @@ module Fluent
|
|
33
35
|
@default_notify = conf['default_notify'] || 0
|
34
36
|
@default_color = conf['default_color'] || 'yellow'
|
35
37
|
@default_format = conf['default_format'] || 'html'
|
38
|
+
@default_timeout = conf['default_timeout']
|
36
39
|
if conf['http_proxy_host']
|
37
40
|
HipChat::API.http_proxy(
|
38
41
|
conf['http_proxy_host'],
|
@@ -49,7 +52,7 @@ module Fluent
|
|
49
52
|
def write(chunk)
|
50
53
|
chunk.msgpack_each do |(tag,time,record)|
|
51
54
|
begin
|
52
|
-
send_message(record) if record[
|
55
|
+
send_message(record) if record[@key_name]
|
53
56
|
set_topic(record) if record['topic']
|
54
57
|
rescue => e
|
55
58
|
$log.error("HipChat Error:", :error_class => e.class, :error => e.message)
|
@@ -60,7 +63,7 @@ module Fluent
|
|
60
63
|
def send_message(record)
|
61
64
|
room = record['room'] || @default_room
|
62
65
|
from = record['from'] || @default_from
|
63
|
-
message = record[
|
66
|
+
message = record[@key_name]
|
64
67
|
if record['notify'].nil?
|
65
68
|
notify = @default_notify
|
66
69
|
else
|
@@ -68,8 +71,9 @@ module Fluent
|
|
68
71
|
end
|
69
72
|
color = COLORS.include?(record['color']) ? record['color'] : @default_color
|
70
73
|
message_format = FORMAT.include?(record['format']) ? record['format'] : @default_format
|
74
|
+
@hipchat.set_timeout(@default_timeout.to_i) unless @default_timeout.nil?
|
71
75
|
response = @hipchat.rooms_message(room, from, message, notify, color, message_format)
|
72
|
-
raise StandardError, response['error'][
|
76
|
+
raise StandardError, response['error'][@key_name].to_s if defined?(response['error'][@key_name])
|
73
77
|
end
|
74
78
|
|
75
79
|
def set_topic(record)
|
@@ -77,7 +81,7 @@ module Fluent
|
|
77
81
|
from = record['from'] || @default_from
|
78
82
|
topic = record['topic']
|
79
83
|
response = @hipchat.rooms_topic(room, topic, from)
|
80
|
-
raise StandardError, response['error'][
|
84
|
+
raise StandardError, response['error'][@key_name].to_s if defined?(response['error'][@key_name])
|
81
85
|
end
|
82
86
|
end
|
83
87
|
end
|
data/test/plugin/out_hipchat.rb
CHANGED
@@ -39,6 +39,17 @@ class HipchatOutputTest < Test::Unit::TestCase
|
|
39
39
|
d.run
|
40
40
|
end
|
41
41
|
|
42
|
+
def test_set_default_timeout
|
43
|
+
d = create_driver(<<-EOF)
|
44
|
+
type hipchat
|
45
|
+
api_token xxx
|
46
|
+
default_timeout 5
|
47
|
+
EOF
|
48
|
+
stub(d.instance.hipchat).set_timeout(5)
|
49
|
+
d.emit({'message' => 'foo'})
|
50
|
+
d.run
|
51
|
+
end
|
52
|
+
|
42
53
|
def test_message
|
43
54
|
d = create_driver
|
44
55
|
stub(d.instance.hipchat).rooms_message('testroom', 'testuser', 'foo', 0, 'red', 'html')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-hipchat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuichi Tateno
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|