fluent-plugin-slack 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWRmYTBmOWJmOTMzYzk4NjgyZmE4MmZhMmZmODNmMmIxZmJiZTFiYw==
4
+ ODA4MDM5NWYzOGM1MzhlYWRkMmUzZWI2Mjg4ODkzNDFiYjRkN2RhOQ==
5
5
  data.tar.gz: !binary |-
6
- ZjkxZDJiZDA1MjI4YTljOTVlOGIxOTc4OTg5ZWY0Yjg1YTIyMzI1YQ==
6
+ MjYxOTZhMDQxY2VmODhhNDQyMGE1N2ZjODZlOTI1YjkwNTExYzVhMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDAyOTdkYTdkNDg0Y2Y3NTMzMjQ4NTBhNmY4MTM4YTJkYTk5NDMyOWI1ZTJk
10
- ZWNmOTM0OGUwODMxMjk2OTJhMWQ4Y2ZlZjBmNzVhMWRjZDUwNGRjOTQxNWJk
11
- YjhjNjE0ZjNlZTlmZjNlOGM1ZThkNGNhMTU2Nzc2YzI3NzJiM2I=
9
+ NzA0N2JiMGRjZmVjYWRmYmM2ZTM0ZDQ1OWM1YTNiYTJkNTQxZjhhNTc1ZDRj
10
+ YTJjZWUwY2RkZTc2Y2U3NGZlZTJlNTliN2RlMGM2OGI1NWNhZmNmMWE4OWIy
11
+ NTFjMzkxMmU1NjAxMWRlN2EyMjlhYTZlODM1NGNkYjA0OWU0Mjc=
12
12
  data.tar.gz: !binary |-
13
- Y2MxNjg5OTA5ZTM3NzY1Mjc0YjEwNzNkZmE0OWVkNTFjNjZiZjQxY2RmNjQz
14
- YWFhYjU5ZmI0MjczMWZjMTI5Mjk4OGExOTE4YzdjZTlkM2EyZDcyNTE3OTRi
15
- ZTAyNjM1MDMxYWEyYTc3NTYyMjkwMDJkMjA2NWViOTBhNzcwZTA=
13
+ MTAzMDk3NWY3NTMzZWIyZGVlNTAwZjYzMmEzM2QzNTE5ZDgwOWI1MjQyODRi
14
+ ZWMzNTQwMTc0N2FiZDc5YTRhMjc4OGJhMGMyOTg3MmMzNWM2OGI2MDExM2Qz
15
+ MTA0YWU2NGU5MWVkZjg0ZTgyNzE5ZTM2MjNkZGJkYmViMTAyMTc=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.1.0
@@ -11,33 +11,33 @@ module Fluent
11
11
  attr_reader :slack
12
12
 
13
13
  def format(tag, time, record)
14
- [tag, time, record].to_json + "\n"
14
+ [tag, time, record].to_msgpack
15
15
  end
16
16
 
17
17
  def write(chunk)
18
18
  messages = {}
19
- chunk.msgpack_each do |(tag, time, record)|
20
- messages[tag] = '' unless messages[tag]
19
+ chunk.msgpack_each do |tag, time, record|
20
+ messages[tag] = '' if messages[tag].nil?
21
21
  messages[tag] << "[#{Time.at(time)}] #{record['message']}\n"
22
22
  end
23
23
  messages.each do |tag, value|
24
- filed = {
24
+ field = {
25
25
  title: tag,
26
26
  value: value
27
27
  }
28
28
  @slack.say(
29
29
  nil,
30
- channel: @channel,
31
- username: @username,
32
- icon_emoji: @icon_emoji,
33
- attachments: {
34
- fallback: tag,
35
- color: @color,
36
- fields: [ field ]
37
- })
30
+ { channel: @channel,
31
+ username: @username,
32
+ icon_emoji: @icon_emoji,
33
+ attachments: [{
34
+ fallback: tag,
35
+ color: @color,
36
+ fields: [ field ]
37
+ }]})
38
38
  end
39
39
  rescue => e
40
- $log.error("Slack Error: #{e} / #{e.message}")
40
+ $log.error("Slack Error: #{e.backtrace[0]} / #{e.message}")
41
41
  end
42
42
 
43
43
  def initialize
@@ -48,7 +48,7 @@ module Fluent
48
48
  def configure(conf)
49
49
  super
50
50
  @slack = Slackr::Webhook.new(conf['team'], conf['api_key'])
51
- @channel = conf['channel']
51
+ @channel = '#' + conf['channel']
52
52
  @username = conf['username'] || 'fluentd'
53
53
  @color = conf['color'] || 'good'
54
54
  @icon_emoji = conf['icon_emoji'] || ':question:'
@@ -17,8 +17,8 @@ class BufferedSlackOutputTest < Test::Unit::TestCase
17
17
  username testuser
18
18
  color good
19
19
  icon_emoji :ghost:
20
- buffer_type memory
21
20
  compress gz
21
+ buffer_path ./test/tmp
22
22
  utc
23
23
  ]
24
24
 
@@ -29,8 +29,22 @@ class BufferedSlackOutputTest < Test::Unit::TestCase
29
29
  def test_format
30
30
  d = create_driver
31
31
  time = Time.parse("2014-01-01 22:00:00 UTC").to_i
32
+ d.tag = 'test'
33
+ stub(d.instance.slack).say(
34
+ nil,
35
+ channel: '#test',
36
+ username: 'testuser',
37
+ icon_emoji: ':ghost:',
38
+ attachments: [{
39
+ fallback: d.tag,
40
+ color: 'good',
41
+ fields: [
42
+ {
43
+ title: d.tag,
44
+ value: "[#{Time.at(time)}] sowawa\n"
45
+ }]}])
32
46
  d.emit({message: 'sowawa'}, time)
33
- d.expect_format %[#{['test', time, {message: 'sowawa'}].to_json}\n]
47
+ d.expect_format %[#{['test', time, {message: 'sowawa'}].to_msgpack}]
34
48
  d.run
35
49
  end
36
50
 
@@ -40,17 +54,18 @@ class BufferedSlackOutputTest < Test::Unit::TestCase
40
54
  d.tag = 'test'
41
55
  stub(d.instance.slack).say(
42
56
  nil,
43
- channel: 'test',
57
+ channel: '#test',
44
58
  username: 'testuser',
45
- icon_emoji: 'ghost',
46
- attachments: {
59
+ icon_emoji: ':ghost:',
60
+ attachments: [{
47
61
  fallback: d.tag,
48
62
  color: 'good',
49
63
  fields: [
50
- "[#{Time.at(time)}] sowawa1\n" +
51
- "[#{Time.at(time)}] sowawa2\n"
52
- ]
53
- })
64
+ {
65
+ title: d.tag,
66
+ value: "[#{Time.at(time)}] sowawa1\n" +
67
+ "[#{Time.at(time)}] sowawa2\n"
68
+ }]}])
54
69
  d.emit({message: 'sowawa1'}, time)
55
70
  d.emit({message: 'sowawa2'}, time)
56
71
  d.run
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-slack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keisuke SOGAWA