fluentd 0.10.36 → 0.10.37

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fluentd might be problematic. Click here for more details.

@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 29c756777b0a1c1f7e1aa306760485def2792c6f
4
+ data.tar.gz: 78dc6cbf225f2ce1c418a4b9e65b0a214a7518a7
5
+ SHA512:
6
+ metadata.gz: 0937333ccf02b3b3fa11806e117b917d1e10f331881db4aa2bb5934ac57a1e75765bfa529683904d91e9fd41464e834981fc54f59adf9bb1ca6c0c42b803bc16
7
+ data.tar.gz: bac6fa8072ece0d4479a3a75e00b5274b2a28454be52785856384748af98c594daae353d5f5c7a607ef966094cb97e31dea6ca4b6a362b14be9ec331653dc973
@@ -1,7 +1,6 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 1.9.2
5
4
  - 1.9.3
6
5
  - 2.0.0
7
6
  - rbx-19mode
@@ -9,5 +8,6 @@ rvm:
9
8
  branches:
10
9
  only:
11
10
  - master
11
+ - v11
12
12
 
13
- script: bundle exec rake test
13
+ script: bundle exec rake
data/ChangeLog CHANGED
@@ -1,3 +1,11 @@
1
+ Release 0.10.37 - 2013/08/29
2
+
3
+ * in_exec: Add format option to support tsv, json and msgpack. Default is tsv
4
+ * out_stdout: Add output_type to print non-jsonable object
5
+ * Engine: Skip nil record in emit
6
+ * Check buffere_path duplication across buffer configurations.
7
+ * Add experimental DSL to configuration format
8
+
1
9
  Release 0.10.36 - 2013/07/31
2
10
 
3
11
  * Log: add class name on each error logs
@@ -16,369 +16,365 @@
16
16
  # limitations under the License.
17
17
  #
18
18
  module Fluent
19
+ class ConfigError < StandardError
20
+ end
19
21
 
22
+ class ConfigParseError < ConfigError
23
+ end
20
24
 
21
- class ConfigError < StandardError
22
- end
23
25
 
24
- class ConfigParseError < ConfigError
25
- end
26
+ module Config
27
+ class Element < Hash
28
+ def initialize(name, arg, attrs, elements, used=[])
29
+ @name = name
30
+ @arg = arg
31
+ @elements = elements
32
+ super()
33
+ attrs.each {|k,v|
34
+ self[k] = v
35
+ }
36
+ @used = used
37
+ end
26
38
 
39
+ attr_accessor :name, :arg, :elements, :used
27
40
 
28
- module Config
29
- class Element < Hash
30
- def initialize(name, arg, attrs, elements, used=[])
31
- @name = name
32
- @arg = arg
33
- @elements = elements
34
- super()
35
- attrs.each {|k,v|
36
- self[k] = v
37
- }
38
- @used = used
39
- end
41
+ def add_element(name, arg='')
42
+ e = Element.new(name, arg, {}, [])
43
+ @elements << e
44
+ e
45
+ end
40
46
 
41
- attr_accessor :name, :arg, :elements, :used
47
+ def +(o)
48
+ Element.new(@name.dup, @arg.dup, o.merge(self), @elements+o.elements, @used+o.used)
49
+ end
42
50
 
43
- def add_element(name, arg='')
44
- e = Element.new(name, arg, {}, [])
45
- @elements << e
46
- e
47
- end
51
+ def has_key?(key)
52
+ @used << key
53
+ super
54
+ end
55
+
56
+ def [](key)
57
+ @used << key
58
+ super
59
+ end
60
+
61
+ def check_not_fetched(&block)
62
+ each_key {|key|
63
+ unless @used.include?(key)
64
+ block.call(key, self)
65
+ end
66
+ }
67
+ @elements.each {|e|
68
+ e.check_not_fetched(&block)
69
+ }
70
+ end
48
71
 
49
- def +(o)
50
- Element.new(@name.dup, @arg.dup, o.merge(self), @elements+o.elements, @used+o.used)
72
+ def to_s(nest = 0)
73
+ indent = " "*nest
74
+ nindent = " "*(nest+1)
75
+ out = ""
76
+ if @arg.empty?
77
+ out << "#{indent}<#{@name}>\n"
78
+ else
79
+ out << "#{indent}<#{@name} #{@arg}>\n"
80
+ end
81
+ each_pair {|k,v|
82
+ out << "#{nindent}#{k} #{v}\n"
83
+ }
84
+ @elements.each {|e|
85
+ out << e.to_s(nest+1)
86
+ }
87
+ out << "#{indent}</#{@name}>\n"
88
+ out
89
+ end
51
90
  end
52
91
 
53
- def has_key?(key)
54
- @used << key
55
- super
92
+ def self.read(path)
93
+ Parser.read(path)
56
94
  end
57
95
 
58
- def [](key)
59
- @used << key
60
- super
96
+ def self.parse(str, fname, basepath=Dir.pwd)
97
+ Parser.parse(str, fname, basepath)
61
98
  end
62
99
 
63
- def check_not_fetched(&block)
64
- each_key {|key|
65
- unless @used.include?(key)
66
- block.call(key, self)
67
- end
68
- }
69
- @elements.each {|e|
70
- e.check_not_fetched(&block)
71
- }
100
+ def self.new(name='')
101
+ Element.new('', '', {}, [])
72
102
  end
73
103
 
74
- def to_s(nest = 0)
75
- indent = " "*nest
76
- nindent = " "*(nest+1)
77
- out = ""
78
- if @arg.empty?
79
- out << "#{indent}<#{@name}>\n"
104
+ def self.size_value(str)
105
+ case str.to_s
106
+ when /([0-9]+)k/i
107
+ $~[1].to_i * 1024
108
+ when /([0-9]+)m/i
109
+ $~[1].to_i * (1024**2)
110
+ when /([0-9]+)g/i
111
+ $~[1].to_i * (1024**3)
112
+ when /([0-9]+)t/i
113
+ $~[1].to_i * (1024**4)
80
114
  else
81
- out << "#{indent}<#{@name} #{@arg}>\n"
115
+ str.to_i
82
116
  end
83
- each_pair {|k,v|
84
- out << "#{nindent}#{k} #{v}\n"
85
- }
86
- @elements.each {|e|
87
- out << e.to_s(nest+1)
88
- }
89
- out << "#{indent}</#{@name}>\n"
90
- out
91
117
  end
92
- end
93
-
94
- def self.read(path)
95
- Parser.read(path)
96
- end
97
-
98
- def self.parse(str, fname, basepath=Dir.pwd)
99
- Parser.parse(str, fname, basepath)
100
- end
101
-
102
- def self.new(name='')
103
- Element.new('', '', {}, [])
104
- end
105
-
106
- def self.size_value(str)
107
- case str.to_s
108
- when /([0-9]+)k/i
109
- $~[1].to_i * 1024
110
- when /([0-9]+)m/i
111
- $~[1].to_i * (1024**2)
112
- when /([0-9]+)g/i
113
- $~[1].to_i * (1024**3)
114
- when /([0-9]+)t/i
115
- $~[1].to_i * (1024**4)
116
- else
117
- str.to_i
118
- end
119
- end
120
118
 
121
- def self.time_value(str)
122
- case str.to_s
123
- when /([0-9]+)s/
124
- $~[1].to_i
125
- when /([0-9]+)m/
126
- $~[1].to_i * 60
127
- when /([0-9]+)h/
128
- $~[1].to_i * 60*60
129
- when /([0-9]+)d/
130
- $~[1].to_i * 24*60*60
131
- else
132
- str.to_f
119
+ def self.time_value(str)
120
+ case str.to_s
121
+ when /([0-9]+)s/
122
+ $~[1].to_i
123
+ when /([0-9]+)m/
124
+ $~[1].to_i * 60
125
+ when /([0-9]+)h/
126
+ $~[1].to_i * 60*60
127
+ when /([0-9]+)d/
128
+ $~[1].to_i * 24*60*60
129
+ else
130
+ str.to_f
131
+ end
133
132
  end
134
- end
135
133
 
136
- def self.bool_value(str)
137
- case str.to_s
138
- when 'true', 'yes'
139
- true
140
- when 'false', 'no'
141
- false
142
- else
143
- nil
134
+ def self.bool_value(str)
135
+ case str.to_s
136
+ when 'true', 'yes'
137
+ true
138
+ when 'false', 'no'
139
+ false
140
+ else
141
+ nil
142
+ end
144
143
  end
145
- end
146
144
 
147
- private
148
- class Parser
149
- def self.read(path)
150
- path = File.expand_path(path)
151
- File.open(path) {|io|
152
- parse(io, File.basename(path), File.dirname(path))
153
- }
154
- end
145
+ private
146
+ class Parser
147
+ def self.read(path)
148
+ path = File.expand_path(path)
149
+ File.open(path) {|io|
150
+ parse(io, File.basename(path), File.dirname(path))
151
+ }
152
+ end
155
153
 
156
- def self.parse(io, fname, basepath=Dir.pwd)
157
- attrs, elems = Parser.new(basepath, io.each_line, fname).parse!(true)
158
- Element.new('ROOT', '', attrs, elems)
159
- end
154
+ def self.parse(io, fname, basepath=Dir.pwd)
155
+ attrs, elems = Parser.new(basepath, io.each_line, fname).parse!(true)
156
+ Element.new('ROOT', '', attrs, elems)
157
+ end
160
158
 
161
- def initialize(basepath, iterator, fname, i=0)
162
- @basepath = basepath
163
- @iterator = iterator
164
- @i = i
165
- @fname = fname
166
- end
159
+ def initialize(basepath, iterator, fname, i=0)
160
+ @basepath = basepath
161
+ @iterator = iterator
162
+ @i = i
163
+ @fname = fname
164
+ end
167
165
 
168
- def parse!(allow_include, elem_name=nil, attrs={}, elems=[])
169
- while line = @iterator.next
170
- line.force_encoding('UTF-8')
171
- @i += 1
172
- line.lstrip!
173
- line.gsub!(/\s*(?:\#.*)?$/,'')
174
- if line.empty?
175
- next
176
- elsif m = /^\<([a-zA-Z0-9_]+)\s*(.+?)?\>$/.match(line)
177
- e_name = m[1]
178
- e_arg = m[2] || ""
179
- e_attrs, e_elems = parse!(false, e_name)
180
- elems << Element.new(e_name, e_arg, e_attrs, e_elems)
181
- elsif line == "</#{elem_name}>"
182
- break
183
- elsif m = /^([a-zA-Z0-9_]+)\s*(.*)$/.match(line)
184
- key = m[1]
185
- value = m[2]
186
- if allow_include && key == 'include'
187
- process_include(attrs, elems, value)
166
+ def parse!(allow_include, elem_name=nil, attrs={}, elems=[])
167
+ while line = @iterator.next
168
+ line.force_encoding('UTF-8')
169
+ @i += 1
170
+ line.lstrip!
171
+ line.gsub!(/\s*(?:\#.*)?$/,'')
172
+ if line.empty?
173
+ next
174
+ elsif m = /^\<([a-zA-Z0-9_]+)\s*(.+?)?\>$/.match(line)
175
+ e_name = m[1]
176
+ e_arg = m[2] || ""
177
+ e_attrs, e_elems = parse!(false, e_name)
178
+ elems << Element.new(e_name, e_arg, e_attrs, e_elems)
179
+ elsif line == "</#{elem_name}>"
180
+ break
181
+ elsif m = /^([a-zA-Z0-9_]+)\s*(.*)$/.match(line)
182
+ key = m[1]
183
+ value = m[2]
184
+ if allow_include && key == 'include'
185
+ process_include(attrs, elems, value)
186
+ else
187
+ attrs[key] = value
188
+ end
189
+ next
188
190
  else
189
- attrs[key] = value
191
+ raise ConfigParseError, "parse error at #{@fname} line #{@i}"
190
192
  end
191
- next
192
- else
193
- raise ConfigParseError, "parse error at #{@fname} line #{@i}"
194
193
  end
194
+
195
+ return attrs, elems
196
+ rescue StopIteration
197
+ return attrs, elems
195
198
  end
196
199
 
197
- return attrs, elems
198
- rescue StopIteration
199
- return attrs, elems
200
- end
200
+ def process_include(attrs, elems, uri)
201
+ u = URI.parse(uri)
202
+ if u.scheme == 'file' || u.path == uri # file path
203
+ path = u.path
204
+ if path[0] != ?/
205
+ pattern = File.expand_path("#{@basepath}/#{path}")
206
+ else
207
+ pattern = path
208
+ end
201
209
 
202
- def process_include(attrs, elems, uri)
203
- u = URI.parse(uri)
204
- if u.scheme == 'file' || u.path == uri # file path
205
- path = u.path
206
- if path[0] != ?/
207
- pattern = File.expand_path("#{@basepath}/#{path}")
208
- else
209
- pattern = path
210
- end
210
+ Dir.glob(pattern).each {|path|
211
+ basepath = File.dirname(path)
212
+ fname = File.basename(path)
213
+ File.open(path) {|f|
214
+ Parser.new(basepath, f.each_line, fname).parse!(true, nil, attrs, elems)
215
+ }
216
+ }
211
217
 
212
- Dir.glob(pattern).each {|path|
213
- basepath = File.dirname(path)
214
- fname = File.basename(path)
215
- File.open(path) {|f|
218
+ else
219
+ basepath = '/'
220
+ fname = path
221
+ require 'open-uri'
222
+ open(uri) {|f|
216
223
  Parser.new(basepath, f.each_line, fname).parse!(true, nil, attrs, elems)
217
224
  }
218
- }
225
+ end
219
226
 
220
- else
221
- basepath = '/'
222
- fname = path
223
- require 'open-uri'
224
- open(uri) {|f|
225
- Parser.new(basepath, f.each_line, fname).parse!(true, nil, attrs, elems)
226
- }
227
+ rescue SystemCallError
228
+ raise ConfigParseError, "include error at #{@fname} line #{@i}: #{$!.to_s}"
227
229
  end
228
-
229
- rescue SystemCallError
230
- raise ConfigParseError, "include error at #{@fname} line #{@i}: #{$!.to_s}"
231
230
  end
232
231
  end
233
- end
234
-
235
-
236
- module Configurable
237
- attr_reader :config
238
232
 
239
- def self.included(mod)
240
- mod.extend(ClassMethods)
241
- end
242
233
 
243
- def initialize
244
- self.class.config_defaults.each_pair {|name,defval|
245
- varname = :"@#{name}"
246
- instance_variable_set(varname, defval)
247
- }
248
- end
234
+ module Configurable
235
+ attr_reader :config
249
236
 
250
- def configure(conf)
251
- @config = conf
237
+ def self.included(mod)
238
+ mod.extend(ClassMethods)
239
+ end
252
240
 
253
- self.class.config_params.each_pair {|name,(block,opts)|
254
- varname = :"@#{name}"
255
- if val = conf[name.to_s]
256
- val = self.instance_exec(val, opts, name, &block)
257
- instance_variable_set(varname, val)
258
- end
259
- unless instance_variable_defined?(varname)
260
- $log.error "config error in:\n#{conf}"
261
- raise ConfigError, "'#{name}' parameter is required"
262
- end
263
- }
264
- end
241
+ def initialize
242
+ self.class.config_defaults.each_pair {|name,defval|
243
+ varname = :"@#{name}"
244
+ instance_variable_set(varname, defval)
245
+ }
246
+ end
265
247
 
266
- module ClassMethods
267
- def config_param(name, *args, &block)
268
- name = name.to_sym
248
+ def configure(conf)
249
+ @config = conf
269
250
 
270
- opts = {}
271
- args.each {|a|
272
- if a.is_a?(Symbol)
273
- opts[:type] = a
274
- elsif a.is_a?(Hash)
275
- opts.merge!(a)
276
- else
277
- raise ArgumentError, "wrong number of arguments (#{1+args.length} for #{block ? 2 : 3})"
251
+ self.class.config_params.each_pair {|name,(block,opts)|
252
+ varname = :"@#{name}"
253
+ if val = conf[name.to_s]
254
+ val = self.instance_exec(val, opts, name, &block)
255
+ instance_variable_set(varname, val)
256
+ end
257
+ unless instance_variable_defined?(varname)
258
+ $log.error "config error in:\n#{conf}"
259
+ raise ConfigError, "'#{name}' parameter is required"
278
260
  end
279
261
  }
262
+ end
280
263
 
281
- type = opts[:type]
282
- if block && type
283
- raise ArgumentError, "wrong number of arguments (#{1+args.length} for #{block ? 2 : 3})"
284
- end
264
+ module ClassMethods
265
+ def config_param(name, *args, &block)
266
+ name = name.to_sym
285
267
 
286
- block ||= case type
287
- when :string, nil
288
- Proc.new {|val| val }
289
- when :integer
290
- Proc.new {|val| val.to_i }
291
- when :float
292
- Proc.new {|val| val.to_f }
293
- when :size
294
- Proc.new {|val| Config.size_value(val) }
295
- when :bool
296
- Proc.new {|val| Config.bool_value(val) }
297
- when :time
298
- Proc.new {|val| Config.time_value(val) }
268
+ opts = {}
269
+ args.each {|a|
270
+ if a.is_a?(Symbol)
271
+ opts[:type] = a
272
+ elsif a.is_a?(Hash)
273
+ opts.merge!(a)
299
274
  else
300
- raise ArgumentError, "unknown config_param type `#{type}'"
275
+ raise ArgumentError, "wrong number of arguments (#{1+args.length} for #{block ? 2 : 3})"
301
276
  end
277
+ }
302
278
 
303
- params = config_params_set
304
- params.delete(name)
305
- params[name] = [block, opts]
279
+ type = opts[:type]
280
+ if block && type
281
+ raise ArgumentError, "wrong number of arguments (#{1+args.length} for #{block ? 2 : 3})"
282
+ end
306
283
 
307
- if opts.has_key?(:default)
308
- config_set_default(name, opts[:default])
284
+ block ||= case type
285
+ when :string, nil
286
+ Proc.new {|val| val }
287
+ when :integer
288
+ Proc.new {|val| val.to_i }
289
+ when :float
290
+ Proc.new {|val| val.to_f }
291
+ when :size
292
+ Proc.new {|val| Config.size_value(val) }
293
+ when :bool
294
+ Proc.new {|val| Config.bool_value(val) }
295
+ when :time
296
+ Proc.new {|val| Config.time_value(val) }
297
+ else
298
+ raise ArgumentError, "unknown config_param type `#{type}'"
299
+ end
300
+
301
+ params = config_params_set
302
+ params.delete(name)
303
+ params[name] = [block, opts]
304
+
305
+ if opts.has_key?(:default)
306
+ config_set_default(name, opts[:default])
307
+ end
308
+
309
+ attr_accessor name
309
310
  end
310
311
 
311
- attr_accessor name
312
- end
312
+ def config_set_default(name, defval)
313
+ name = name.to_sym
313
314
 
314
- def config_set_default(name, defval)
315
- name = name.to_sym
315
+ defaults = config_defaults_set
316
+ defaults.delete(name)
317
+ defaults[name] = defval
316
318
 
317
- defaults = config_defaults_set
318
- defaults.delete(name)
319
- defaults[name] = defval
319
+ nil
320
+ end
320
321
 
321
- nil
322
- end
322
+ def config_params
323
+ singleton_value(:_config_params)
324
+ end
323
325
 
324
- def config_params
325
- singleton_value(:_config_params)
326
- end
326
+ def config_defaults
327
+ singleton_value(:_config_defaults)
328
+ end
327
329
 
328
- def config_defaults
329
- singleton_value(:_config_defaults)
330
- end
330
+ private
331
+ def config_params_set
332
+ singleton_value_set(:_config_params)
333
+ end
331
334
 
332
- private
333
- def config_params_set
334
- singleton_value_set(:_config_params)
335
- end
335
+ def config_defaults_set
336
+ singleton_value_set(:_config_defaults)
337
+ end
336
338
 
337
- def config_defaults_set
338
- singleton_value_set(:_config_defaults)
339
- end
339
+ def singleton_value_set(name)
340
+ if methods(false).include?(name)
341
+ __send__(name)
342
+ else
343
+ val = {}
344
+ define_singleton_method(name) { val }
345
+ val
346
+ end
347
+ end
340
348
 
341
- def singleton_value_set(name)
342
- if methods(false).include?(name)
343
- __send__(name)
344
- else
349
+ def singleton_value(name)
345
350
  val = {}
346
- define_singleton_method(name) { val }
351
+ ancestors.reverse_each {|c|
352
+ if c.methods(false).include?(name)
353
+ val.merge!(c.__send__(name))
354
+ end
355
+ }
347
356
  val
348
357
  end
349
358
  end
350
-
351
- def singleton_value(name)
352
- val = {}
353
- ancestors.reverse_each {|c|
354
- if c.methods(false).include?(name)
355
- val.merge!(c.__send__(name))
356
- end
357
- }
358
- val
359
- end
360
359
  end
361
- end
362
360
 
363
361
 
364
- module PluginId
365
- def configure(conf)
366
- @id = conf['id']
367
- super
368
- end
362
+ module PluginId
363
+ def configure(conf)
364
+ @id = conf['id']
365
+ super
366
+ end
369
367
 
370
- def require_id
371
- unless @id
372
- raise ConfigError, "'id' parameter is required"
368
+ def require_id
369
+ unless @id
370
+ raise ConfigError, "'id' parameter is required"
371
+ end
372
+ @id
373
373
  end
374
- @id
375
- end
376
374
 
377
- def plugin_id
378
- @id ? @id : "object:#{object_id.to_s(16)}"
375
+ def plugin_id
376
+ @id ? @id : "object:#{object_id.to_s(16)}"
377
+ end
379
378
  end
380
379
  end
381
380
 
382
-
383
- end
384
-