fluent-plugin-map 0.0.3 → 0.0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "fluent-plugin-map"
6
- s.version = "0.0.3"
6
+ s.version = "0.0.3.1"
7
7
  s.authors = ["Kohei Tomita"]
8
8
  s.email = ["tommy.fmale@gmail.com"]
9
9
  s.homepage = "https://github.com/tomity/fluent-plugin-map"
@@ -4,7 +4,8 @@ module Fluent
4
4
  Fluent::Plugin.register_output('map', self)
5
5
 
6
6
  config_param :map, :string, :default => nil
7
- config_param :key, :string, :default => nil
7
+ config_param :tag, :string, :default => nil
8
+ config_param :key, :string, :default => nil #deprected
8
9
  config_param :time, :string, :default => nil
9
10
  config_param :record, :string, :default => nil
10
11
  config_param :multi, :bool, :default => false
@@ -14,9 +15,10 @@ module Fluent
14
15
  if @map
15
16
  $log.debug { "map: #{@map}" }
16
17
  @mode = "tuple"
17
- elsif @key && @time && @record
18
- raise ConfigError, "multi and 3 parameters(key, time, and record) are not compatible" if @multi
19
- $log.debug { "key: #{@key}, time: #{@time}, record: #{@record}" }
18
+ elsif (@tag || @key) && @time && @record
19
+ @tag ||= @key
20
+ raise ConfigError, "multi and 3 parameters(tag, time, and record) are not compatible" if @multi
21
+ $log.debug { "tag: #{@tag}, time: #{@time}, record: #{@record}" }
20
22
  @mode = "each"
21
23
  else
22
24
  raise ConfigError, "Either map or 3 parameters(key, time, and record) is required "
@@ -36,10 +38,10 @@ module Fluent
36
38
  tuples << new_tuple
37
39
  end
38
40
  when "each"
39
- new_key = eval(@key)
41
+ new_tag = eval(@tag)
40
42
  new_time = eval(@time)
41
43
  new_record = eval(@record)
42
- tuples << [new_key, new_time, new_record]
44
+ tuples << [new_tag, new_time, new_record]
43
45
  end
44
46
  }
45
47
  tuples.each do |tag, time, record|
@@ -80,6 +80,25 @@ class MapOutputTest < Test::Unit::TestCase
80
80
  assert e.kind_of?(SyntaxError)
81
81
  end
82
82
 
83
+ def test_tag_convert_using_tag_time_record
84
+ tag = 'tag'
85
+ time = Time.local(2012, 10, 10, 10, 10, 10)
86
+ record = {'code' => '300'}
87
+
88
+ d1 = create_driver %[
89
+ tag "newtag"
90
+ time time
91
+ record record
92
+ ], tag
93
+ d1.run do
94
+ d1.emit(record, time)
95
+ end
96
+ emits = d1.emits
97
+ assert_equal 1, emits.length
98
+ assert_equal ["newtag", time.to_i, record], emits[0]
99
+ end
100
+
101
+ #deprected specification test
83
102
  def test_tag_convert_using_key_time_record
84
103
  tag = 'tag'
85
104
  time = Time.local(2012, 10, 10, 10, 10, 10)
@@ -98,7 +117,7 @@ class MapOutputTest < Test::Unit::TestCase
98
117
  assert_equal ["newtag", time.to_i, record], emits[0]
99
118
  end
100
119
 
101
- def test_config_error_key
120
+ def test_config_error_tag
102
121
  tag = "tag"
103
122
  time = Time.local(2012, 10, 10, 10, 10, 0)
104
123
  record = {'code' => '300'}
@@ -119,7 +138,7 @@ class MapOutputTest < Test::Unit::TestCase
119
138
  #require time
120
139
  assert_raise(Fluent::ConfigError){
121
140
  create_driver %[
122
- key "newtag"
141
+ tag "newtag"
123
142
  record record
124
143
  ], tag
125
144
  }
@@ -132,7 +151,7 @@ class MapOutputTest < Test::Unit::TestCase
132
151
  #require record
133
152
  assert_raise(Fluent::ConfigError){
134
153
  create_driver %[
135
- key "newtag"
154
+ tag "newtag"
136
155
  time time
137
156
  ], tag
138
157
  }
@@ -147,7 +166,7 @@ class MapOutputTest < Test::Unit::TestCase
147
166
  #require time
148
167
  assert_raise(Fluent::ConfigError){
149
168
  create_driver %[
150
- key "newtag"
169
+ tag "newtag"
151
170
  time time
152
171
  record record
153
172
  multi true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-map
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-08-11 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70263359418000 !ruby/object:Gem::Requirement
16
+ requirement: &70202612149300 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.9.2.2
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70263359418000
24
+ version_requirements: *70202612149300
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: fluentd
27
- requirement: &70263359417460 !ruby/object:Gem::Requirement
27
+ requirement: &70202612148700 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: 0.10.24
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70263359417460
35
+ version_requirements: *70202612148700
36
36
  description: ! 'fluent-plugin-map is the non-buffered plugin that can convert an event
37
37
  log to different event log(s). '
38
38
  email: