fluentd 0.10.2 → 0.10.3

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.

data/ChangeLog CHANGED
@@ -1,11 +1,17 @@
1
1
 
2
+ Release 0.10.3 - 2011/10/21
3
+
4
+ * Supports 'include' in config file
5
+ * Supports "http://" schema
6
+ * Supports wildcards
7
+
8
+
2
9
  Release 0.10.2 - 2011/10/18
3
10
 
4
11
  * Fixed EventStream#to_msgpack_stream (thanks CkReal)
5
12
  * Added gemspec.required_ruby_version = '~> 1.9.2' (thanks sakuro)
6
13
 
7
14
 
8
-
9
15
  Release 0.10.1 - 2011/10/16
10
16
 
11
17
  * SetTimeKeyMixin accepts include_time_key parameter
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.2
1
+ 0.10.3
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fluentd}
8
- s.version = "0.10.2"
8
+ s.version = "0.10.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Sadayuki Furuhashi"]
12
- s.date = %q{2011-10-18}
12
+ s.date = %q{2011-10-21}
13
13
  s.email = %q{frsyuki@gmail.com}
14
14
  s.executables = ["fluentd", "fluent-cat", "fluent-gem"]
15
15
  s.extra_rdoc_files = [
@@ -60,6 +60,7 @@ Gem::Specification.new do |s|
60
60
  "lib/fluent/test/input_test.rb",
61
61
  "lib/fluent/test/output_test.rb",
62
62
  "lib/fluent/version.rb",
63
+ "test/config.rb",
63
64
  "test/helper.rb",
64
65
  "test/match.rb",
65
66
  "test/plugin/in_http.rb",
@@ -76,7 +77,8 @@ Gem::Specification.new do |s|
76
77
  s.rubygems_version = %q{1.3.7}
77
78
  s.summary = %q{Fluent event collector}
78
79
  s.test_files = [
79
- "test/helper.rb",
80
+ "test/config.rb",
81
+ "test/helper.rb",
80
82
  "test/match.rb",
81
83
  "test/plugin/in_http.rb",
82
84
  "test/plugin/in_stream.rb",
@@ -92,13 +92,11 @@ module Config
92
92
  end
93
93
 
94
94
  def self.read(path)
95
- parse(File.read(path), File.basename(path))
95
+ Parser.read(path)
96
96
  end
97
97
 
98
- def self.parse(str, fname)
99
- lines = str.split("\n")
100
- i, attrs, elems = parse_element('end', lines, 0, fname)
101
- Element.new('ROOT', '', attrs, elems)
98
+ def self.parse(str, fname, basepath=Dir.pwd)
99
+ Parser.parse(str, fname, basepath)
102
100
  end
103
101
 
104
102
  def self.new(name='')
@@ -147,33 +145,89 @@ module Config
147
145
  end
148
146
 
149
147
  private
150
- def self.parse_element(name, lines, i, fname)
151
- attrs = {}
152
- elems = []
153
- while i < lines.length
154
- line = lines[i]
155
- line.lstrip!
156
- line.gsub!(/\s*(?:\#.*)?$/,'')
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
155
+
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
160
+
161
+ def initialize(basepath, iterator, fname, i=0)
162
+ @basepath = basepath
163
+ @iterator = iterator
164
+ @i = i
165
+ @fname = fname
166
+ end
167
+
168
+ def parse!(allow_include, elem_name=nil, attrs={}, elems=[])
169
+ while line = @iterator.next
170
+ @i += 1
171
+ line.lstrip!
172
+ line.gsub!(/\s*(?:\#.*)?$/,'')
157
173
  if line.empty?
158
- i += 1
159
174
  next
160
175
  elsif m = /^\<([a-zA-Z0-9_]+)\s*(.+?)?\>$/.match(line)
161
176
  e_name = m[1]
162
177
  e_arg = m[2] || ""
163
- i, e_attrs, e_elems = parse_element(e_name, lines, i+1, fname)
178
+ e_attrs, e_elems = parse!(false, e_name)
164
179
  elems << Element.new(e_name, e_arg, e_attrs, e_elems)
165
- elsif line == "</#{name}>"
166
- i += 1
180
+ elsif line == "</#{elem_name}>"
167
181
  break
168
- elsif m = /^([a-zA-Z0-9_]+)\s*(.+)?$/.match(line)
169
- attrs[m[1]] = m[2] || ""
170
- i += 1
182
+ elsif m = /^([a-zA-Z0-9_]+)\s*(.*)$/.match(line)
183
+ key = m[1]
184
+ value = m[2]
185
+ if allow_include && key == 'include'
186
+ process_include(attrs, elems, value)
187
+ else
188
+ attrs[key] = value
189
+ end
171
190
  next
172
191
  else
173
- raise ConfigParseError, "parse error at #{fname}:#{i}"
192
+ raise ConfigParseError, "parse error at #{@fname} line #{@i}"
193
+ end
194
+ end
195
+
196
+ return attrs, elems
197
+ rescue StopIteration
198
+ return attrs, elems
199
+ end
200
+
201
+ def process_include(attrs, elems, uri)
202
+ u = URI.parse(uri)
203
+ if u.scheme == 'file' || u.path == uri # file path
204
+ path = u.path
205
+ if path[0] != ?/
206
+ pattern = File.expand_path("#{@basepath}/#{path}")
207
+ else
208
+ pattern = path
174
209
  end
210
+
211
+ Dir.glob(pattern).each {|path|
212
+ basepath = File.dirname(path)
213
+ fname = File.basename(path)
214
+ File.open(path) {|f|
215
+ Parser.new(basepath, f.each_line, fname).parse!(true, nil, attrs, elems)
216
+ }
217
+ }
218
+
219
+ else
220
+ basepath = '/'
221
+ fname = path
222
+ require 'open-uri'
223
+ open(uri) {|f|
224
+ Parser.new(basepath, f.each_line, fname).parse!(true, nil, attrs, elems)
225
+ }
226
+ end
227
+
228
+ rescue SystemCallError
229
+ raise ConfigParseError, "include error at #{@fname} line #{@i}: #{$!.to_s}"
175
230
  end
176
- return i, attrs, elems
177
231
  end
178
232
  end
179
233
 
@@ -5,6 +5,7 @@ require 'monitor'
5
5
  require 'stringio'
6
6
  require 'fileutils'
7
7
  require 'json'
8
+ require 'uri'
8
9
  require 'msgpack'
9
10
  require 'cool.io'
10
11
  require 'cool.io/eventmachine'
@@ -1,5 +1,5 @@
1
1
  module Fluent
2
2
 
3
- VERSION = '0.10.2'
3
+ VERSION = '0.10.3'
4
4
 
5
5
  end
@@ -0,0 +1,60 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ require 'fluent/config'
4
+ require 'fileutils'
5
+
6
+ class ConfigTest < Test::Unit::TestCase
7
+ include Fluent
8
+
9
+ TMP_DIR = File.dirname(__FILE__) + "/tmp"
10
+
11
+ def test_include
12
+ write_config "#{TMP_DIR}/config_test_1.conf", %[
13
+ k1 root_config
14
+ include dir/config_test_2.conf #
15
+ include #{TMP_DIR}/config_test_4.conf
16
+ include file://#{TMP_DIR}/config_test_5.conf
17
+ include config.d/*.conf
18
+ ]
19
+ write_config "#{TMP_DIR}/dir/config_test_2.conf", %[
20
+ k2 relative_path_include
21
+ include ../config_test_3.conf
22
+ ]
23
+ write_config "#{TMP_DIR}/config_test_3.conf", %[
24
+ k3 relative_include_in_included_file
25
+ ]
26
+ write_config "#{TMP_DIR}/config_test_4.conf", %[
27
+ k4 absolute_path_include
28
+ ]
29
+ write_config "#{TMP_DIR}/config_test_5.conf", %[
30
+ k5 uri_include
31
+ ]
32
+ write_config "#{TMP_DIR}/config.d/config_test_6.conf", %[
33
+ k6 wildcard_include_1
34
+ <elem name>
35
+ include normal_parameter
36
+ </elem>
37
+ ]
38
+ write_config "#{TMP_DIR}/config.d/config_test_7.conf", %[
39
+ k7 wildcard_include_2
40
+ ]
41
+
42
+ c = Config.read("#{TMP_DIR}/config_test_1.conf")
43
+ assert_equal 'root_config', c['k1']
44
+ assert_equal 'relative_path_include', c['k2']
45
+ assert_equal 'relative_include_in_included_file', c['k3']
46
+ assert_equal 'absolute_path_include', c['k4']
47
+ assert_equal 'uri_include', c['k5']
48
+ assert_equal 'wildcard_include_1', c['k6']
49
+ assert_equal 'wildcard_include_2', c['k7']
50
+ assert_equal 'elem', c.elements.first.name
51
+ assert_equal 'name', c.elements.first.arg
52
+ assert_equal 'normal_parameter', c.elements.first['include']
53
+ end
54
+
55
+ def write_config(path, data)
56
+ FileUtils.mkdir_p(File.dirname(path))
57
+ File.open(path, "w") {|f| f.write data }
58
+ end
59
+ end
60
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluentd
3
3
  version: !ruby/object:Gem::Version
4
- hash: 51
4
+ hash: 49
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 10
9
- - 2
10
- version: 0.10.2
9
+ - 3
10
+ version: 0.10.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sadayuki Furuhashi
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-18 00:00:00 +09:00
18
+ date: 2011-10-21 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -169,6 +169,7 @@ files:
169
169
  - lib/fluent/test/input_test.rb
170
170
  - lib/fluent/test/output_test.rb
171
171
  - lib/fluent/version.rb
172
+ - test/config.rb
172
173
  - test/helper.rb
173
174
  - test/match.rb
174
175
  - test/plugin/in_http.rb
@@ -216,6 +217,7 @@ signing_key:
216
217
  specification_version: 3
217
218
  summary: Fluent event collector
218
219
  test_files:
220
+ - test/config.rb
219
221
  - test/helper.rb
220
222
  - test/match.rb
221
223
  - test/plugin/in_http.rb