fluent-plugin-ikachan 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |gem|
|
3
3
|
gem.name = "fluent-plugin-ikachan"
|
4
|
-
gem.version = "0.2.
|
4
|
+
gem.version = "0.2.1"
|
5
5
|
gem.authors = ["TAGOMORI Satoshi"]
|
6
6
|
gem.email = ["tagomoris@gmail.com"]
|
7
7
|
gem.summary = %q{output plugin for IRC-HTTP gateway 'ikachan'}
|
@@ -83,7 +83,9 @@ class Fluent::IkachanOutput < Fluent::Output
|
|
83
83
|
|
84
84
|
messages.each do |msg|
|
85
85
|
begin
|
86
|
-
|
86
|
+
msg.split("\n").each do |m|
|
87
|
+
res = Net::HTTP.post_form(@notice_uri, {'channel' => @channel, 'message' => m})
|
88
|
+
end
|
87
89
|
rescue
|
88
90
|
$log.warn "out_ikachan: failed to send notice to #{@host}:#{@port}, #{@channel}, message: #{msg}"
|
89
91
|
end
|
@@ -91,7 +93,9 @@ class Fluent::IkachanOutput < Fluent::Output
|
|
91
93
|
|
92
94
|
privmsg_messages.each do |msg|
|
93
95
|
begin
|
94
|
-
|
96
|
+
msg.split("\n").each do |m|
|
97
|
+
res = Net::HTTP.post_form(@privmsg_uri, {'channel' => @channel, 'message' => m})
|
98
|
+
end
|
95
99
|
rescue
|
96
100
|
$log.warn "out_ikachan: failed to send privmsg to #{@host}:#{@port}, #{@channel}, message: #{msg}"
|
97
101
|
end
|
@@ -117,7 +121,7 @@ class Fluent::IkachanOutput < Fluent::Output
|
|
117
121
|
end
|
118
122
|
end
|
119
123
|
|
120
|
-
message % values
|
124
|
+
(message % values).gsub(/\\n/, "\n")
|
121
125
|
end
|
122
126
|
|
123
127
|
end
|
@@ -36,6 +36,19 @@ class IkachanOutputTest < Test::Unit::TestCase
|
|
36
36
|
tag_key tag
|
37
37
|
]
|
38
38
|
|
39
|
+
# Please notice that the line feed is "\n" in fluentd config file, not "\\n" as belows:
|
40
|
+
CONFIG_LINE_FEED = %[
|
41
|
+
host localhost
|
42
|
+
channel morischan
|
43
|
+
message out_ikachan: %s [%s] %s\\nRETURN
|
44
|
+
out_keys tag,time,msg
|
45
|
+
privmsg_message out_ikachan: %s [%s] %s\\nRETURN
|
46
|
+
privmsg_out_keys tag,time,msg
|
47
|
+
time_key time
|
48
|
+
time_format %Y/%m/%d %H:%M:%S
|
49
|
+
tag_key tag
|
50
|
+
]
|
51
|
+
|
39
52
|
def create_driver(conf=CONFIG,tag='test')
|
40
53
|
Fluent::Test::OutputTestDriver.new(Fluent::IkachanOutput, tag).configure(conf)
|
41
54
|
end
|
@@ -47,6 +60,8 @@ class IkachanOutputTest < Test::Unit::TestCase
|
|
47
60
|
assert_equal '#morischan', d.instance.channel
|
48
61
|
d = create_driver(CONFIG_PRIVMSG_ONLY)
|
49
62
|
assert_equal '#morischan', d.instance.channel
|
63
|
+
d = create_driver(CONFIG_LINE_FEED)
|
64
|
+
assert_equal '#morischan', d.instance.channel
|
50
65
|
end
|
51
66
|
|
52
67
|
# CONFIG = %[
|
@@ -148,6 +163,59 @@ class IkachanOutputTest < Test::Unit::TestCase
|
|
148
163
|
assert_equal "out_ikachan: test [#{ts}] privmsg message from fluentd out_ikachan: testing second line", @posted[1][:message]
|
149
164
|
end
|
150
165
|
|
166
|
+
# CONFIG = %[
|
167
|
+
# host localhost
|
168
|
+
# channel morischan
|
169
|
+
# message out_ikachan: %s [%s] %s\nRETURN
|
170
|
+
# out_keys tag,time,msg
|
171
|
+
# privmsg_message out_ikachan: %s [%s] %s\nRETURN
|
172
|
+
# privmsg_out_keys tag,time,msg
|
173
|
+
# time_key time
|
174
|
+
# time_format %Y/%m/%d %H:%M:%S
|
175
|
+
# tag_key tag
|
176
|
+
# ]
|
177
|
+
def test_line_feed
|
178
|
+
d = create_driver(CONFIG_LINE_FEED)
|
179
|
+
t = Time.now
|
180
|
+
time = t.to_i
|
181
|
+
ts = t.strftime(d.instance.time_format)
|
182
|
+
d.run do
|
183
|
+
d.emit({'msg' => "both notice and privmsg message from fluentd out_ikachan: testing now\ntesting second line"}, time)
|
184
|
+
end
|
185
|
+
|
186
|
+
assert_equal 6, @posted.length
|
187
|
+
|
188
|
+
i = 0
|
189
|
+
assert_equal 'notice', @posted[i][:method]
|
190
|
+
assert_equal '#morischan', @posted[i][:channel]
|
191
|
+
assert_equal "out_ikachan: test [#{ts}] both notice and privmsg message from fluentd out_ikachan: testing now", @posted[i][:message]
|
192
|
+
|
193
|
+
i += 1
|
194
|
+
assert_equal 'notice', @posted[i][:method]
|
195
|
+
assert_equal '#morischan', @posted[i][:channel]
|
196
|
+
assert_equal "testing second line", @posted[i][:message]
|
197
|
+
|
198
|
+
i += 1
|
199
|
+
assert_equal 'notice', @posted[i][:method]
|
200
|
+
assert_equal '#morischan', @posted[i][:channel]
|
201
|
+
assert_equal "RETURN", @posted[i][:message]
|
202
|
+
|
203
|
+
i += 1
|
204
|
+
assert_equal 'privmsg', @posted[i][:method]
|
205
|
+
assert_equal '#morischan', @posted[i][:channel]
|
206
|
+
assert_equal "out_ikachan: test [#{ts}] both notice and privmsg message from fluentd out_ikachan: testing now", @posted[i][:message]
|
207
|
+
|
208
|
+
i += 1
|
209
|
+
assert_equal 'privmsg', @posted[i][:method]
|
210
|
+
assert_equal '#morischan', @posted[i][:channel]
|
211
|
+
assert_equal "testing second line", @posted[i][:message]
|
212
|
+
|
213
|
+
i += 1
|
214
|
+
assert_equal 'privmsg', @posted[i][:method]
|
215
|
+
assert_equal '#morischan', @posted[i][:channel]
|
216
|
+
assert_equal "RETURN", @posted[i][:message]
|
217
|
+
end
|
218
|
+
|
151
219
|
# setup / teardown for servers
|
152
220
|
def setup
|
153
221
|
Fluent::Test.setup
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-ikachan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|