fluent-plugin-ikachan 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/fluent-plugin-ikachan.gemspec +1 -1
- data/lib/fluent/plugin/out_ikachan.rb +17 -18
- data/test/plugin/test_out_ikachan.rb +49 -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: 4b168b15153134a57ec8833e18f539a2439a78c8
|
4
|
+
data.tar.gz: d8c2a5123dea47b1147f78fa85600aae3ad124a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 253bb4d83c204016719c8cab24dfacaba02438c1eb50ddefeea830a5e769e3bb2b4d4e6135072f5de68db1066f34909977eeaf2c679042f9d3e20e5d031b82ac
|
7
|
+
data.tar.gz: 3b8b0b516cf96f5fe6768ff12fc28b405442751db462324ed0090e38f9829ca49ed0fc4abc42dad076031e750364a9775cf27a5e543f2b4d3f72c68f33769376
|
@@ -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.5"
|
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'}
|
@@ -19,6 +19,7 @@ class Fluent::IkachanOutput < Fluent::Output
|
|
19
19
|
config_param :time_key, :string, :default => nil
|
20
20
|
config_param :time_format, :string, :default => nil
|
21
21
|
config_param :tag_key, :string, :default => 'tag'
|
22
|
+
config_param :post_per_line, :bool, :default => true
|
22
23
|
|
23
24
|
def initialize
|
24
25
|
super
|
@@ -104,31 +105,29 @@ class Fluent::IkachanOutput < Fluent::Output
|
|
104
105
|
end
|
105
106
|
|
106
107
|
def emit(tag, es, chain)
|
107
|
-
|
108
|
-
privmsg_messages = []
|
108
|
+
posts = []
|
109
109
|
|
110
|
-
es.each
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
begin
|
117
|
-
msg.split("\n").each do |m|
|
118
|
-
res = http_post_request(@notice_uri, {'channel' => @channel, 'message' => m})
|
119
|
-
end
|
120
|
-
rescue
|
121
|
-
log.warn "out_ikachan: failed to send notice to #{@host}:#{@port}, #{@channel}, message: #{msg}"
|
110
|
+
es.each do |time,record|
|
111
|
+
if @message
|
112
|
+
posts << [:notice, evaluate_message(@message, @out_keys, tag, time, record)]
|
113
|
+
end
|
114
|
+
if @privmsg_message
|
115
|
+
posts << [:privmsg, evaluate_message(@privmsg_message, @privmsg_out_keys, tag, time, record)]
|
122
116
|
end
|
123
117
|
end
|
124
118
|
|
125
|
-
|
119
|
+
posts.each do |type, msg|
|
120
|
+
uri = (type == :privmsg ? @privmsg_uri : @notice_uri)
|
126
121
|
begin
|
127
|
-
|
128
|
-
|
122
|
+
if @post_per_line
|
123
|
+
msg.split("\n").each do |m|
|
124
|
+
res = http_post_request(uri, {'channel' => @channel, 'message' => m})
|
125
|
+
end
|
126
|
+
else
|
127
|
+
res = http_post_request(uri, {'channel' => @channel, 'message' => msg})
|
129
128
|
end
|
130
129
|
rescue
|
131
|
-
log.warn "out_ikachan: failed to send
|
130
|
+
log.warn "out_ikachan: failed to send notice to #{@host}:#{@port}, #{@channel}, message: #{msg}"
|
132
131
|
end
|
133
132
|
end
|
134
133
|
|
@@ -50,6 +50,19 @@ class IkachanOutputTest < Test::Unit::TestCase
|
|
50
50
|
tag_key tag
|
51
51
|
]
|
52
52
|
|
53
|
+
CONFIG_POST_PER_LINE_FALSE = %[
|
54
|
+
host localhost
|
55
|
+
channel morischan
|
56
|
+
message out_ikachan: %s [%s] %s\\nRETURN
|
57
|
+
out_keys tag,time,msg
|
58
|
+
privmsg_message out_ikachan: %s [%s] %s\\nRETURN
|
59
|
+
privmsg_out_keys tag,time,msg
|
60
|
+
time_key time
|
61
|
+
time_format %Y/%m/%d %H:%M:%S
|
62
|
+
tag_key tag
|
63
|
+
post_per_line false
|
64
|
+
]
|
65
|
+
|
53
66
|
CONFIG_HOST_NIL = %[
|
54
67
|
channel morischan
|
55
68
|
message out_ikachan: %s [%s] %s
|
@@ -140,6 +153,8 @@ class IkachanOutputTest < Test::Unit::TestCase
|
|
140
153
|
assert_equal '#morischan', d.instance.channel
|
141
154
|
d = create_driver(CONFIG_LINE_FEED)
|
142
155
|
assert_equal '#morischan', d.instance.channel
|
156
|
+
d = create_driver(CONFIG_POST_PER_LINE_FALSE)
|
157
|
+
assert_equal '#morischan', d.instance.channel
|
143
158
|
assert_raise Fluent::ConfigError do
|
144
159
|
create_driver(CONFIG_HOST_NIL)
|
145
160
|
end
|
@@ -314,6 +329,40 @@ class IkachanOutputTest < Test::Unit::TestCase
|
|
314
329
|
assert_equal "RETURN", @posted[i][:message]
|
315
330
|
end
|
316
331
|
|
332
|
+
# CONFIG_POST_PER_LINE_FALSE = %[
|
333
|
+
# host localhost
|
334
|
+
# channel morischan
|
335
|
+
# message out_ikachan: %s [%s] %s\\nRETURN
|
336
|
+
# out_keys tag,time,msg
|
337
|
+
# privmsg_message out_ikachan: %s [%s] %s\\nRETURN
|
338
|
+
# privmsg_out_keys tag,time,msg
|
339
|
+
# time_key time
|
340
|
+
# time_format %Y/%m/%d %H:%M:%S
|
341
|
+
# tag_key tag
|
342
|
+
# post_per_line false
|
343
|
+
# ]
|
344
|
+
def test_post_per_line_false
|
345
|
+
d = create_driver(CONFIG_POST_PER_LINE_FALSE)
|
346
|
+
t = Time.now
|
347
|
+
time = t.to_i
|
348
|
+
ts = t.strftime(d.instance.time_format)
|
349
|
+
d.run do
|
350
|
+
d.emit({'msg' => "both notice and privmsg message from fluentd out_ikachan: testing now\ntesting second line"}, time)
|
351
|
+
end
|
352
|
+
|
353
|
+
assert_equal 2, @posted.length
|
354
|
+
|
355
|
+
i = 0
|
356
|
+
assert_equal 'notice', @posted[i][:method]
|
357
|
+
assert_equal '#morischan', @posted[i][:channel]
|
358
|
+
assert_equal "out_ikachan: test [#{ts}] both notice and privmsg message from fluentd out_ikachan: testing now\ntesting second line\nRETURN", @posted[i][:message]
|
359
|
+
|
360
|
+
i += 1
|
361
|
+
assert_equal 'privmsg', @posted[i][:method]
|
362
|
+
assert_equal '#morischan', @posted[i][:channel]
|
363
|
+
assert_equal "out_ikachan: test [#{ts}] both notice and privmsg message from fluentd out_ikachan: testing now\ntesting second line\nRETURN", @posted[i][:message]
|
364
|
+
end
|
365
|
+
|
317
366
|
# CONFIG_BASE_URI = %[
|
318
367
|
# base_uri http://localhost:4979/ikachan/
|
319
368
|
# channel morischan
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TAGOMORI Satoshi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|