fluentd 1.7.4-x64-mingw32 → 1.8.0-x64-mingw32

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.

Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -1
  3. data/.travis.yml +4 -0
  4. data/CHANGELOG.md +70 -0
  5. data/MAINTAINERS.md +1 -0
  6. data/example/out_forward_sd.conf +17 -0
  7. data/example/sd.yaml +8 -0
  8. data/fluentd.gemspec +1 -1
  9. data/lib/fluent/agent.rb +3 -1
  10. data/lib/fluent/command/cat.rb +1 -2
  11. data/lib/fluent/command/fluentd.rb +16 -8
  12. data/lib/fluent/compat/call_super_mixin.rb +9 -0
  13. data/lib/fluent/compat/exec_util.rb +1 -1
  14. data/lib/fluent/config/configure_proxy.rb +4 -4
  15. data/lib/fluent/config/element.rb +28 -15
  16. data/lib/fluent/config/error.rb +6 -0
  17. data/lib/fluent/config/literal_parser.rb +24 -2
  18. data/lib/fluent/config/section.rb +43 -6
  19. data/lib/fluent/config/types.rb +98 -26
  20. data/lib/fluent/configurable.rb +2 -2
  21. data/lib/fluent/counter/base_socket.rb +2 -4
  22. data/lib/fluent/engine.rb +41 -122
  23. data/lib/fluent/event.rb +5 -7
  24. data/lib/fluent/fluent_log_event_router.rb +141 -0
  25. data/lib/fluent/msgpack_factory.rb +19 -2
  26. data/lib/fluent/plugin.rb +10 -1
  27. data/lib/fluent/plugin/base.rb +2 -2
  28. data/lib/fluent/plugin/buf_file.rb +11 -7
  29. data/lib/fluent/plugin/buf_file_single.rb +8 -5
  30. data/lib/fluent/plugin/buffer/chunk.rb +1 -1
  31. data/lib/fluent/plugin/buffer/file_chunk.rb +4 -6
  32. data/lib/fluent/plugin/buffer/file_single_chunk.rb +3 -5
  33. data/lib/fluent/plugin/formatter_csv.rb +23 -1
  34. data/lib/fluent/plugin/formatter_stdout.rb +1 -1
  35. data/lib/fluent/plugin/in_forward.rb +1 -1
  36. data/lib/fluent/plugin/in_monitor_agent.rb +4 -2
  37. data/lib/fluent/plugin/in_tail.rb +6 -0
  38. data/lib/fluent/plugin/in_unix.rb +1 -1
  39. data/lib/fluent/plugin/out_forward.rb +77 -28
  40. data/lib/fluent/plugin/out_forward/ack_handler.rb +1 -1
  41. data/lib/fluent/plugin/out_forward/load_balancer.rb +5 -2
  42. data/lib/fluent/plugin/out_stream.rb +1 -1
  43. data/lib/fluent/plugin/output.rb +11 -3
  44. data/lib/fluent/plugin/parser.rb +1 -0
  45. data/lib/fluent/plugin/sd_file.rb +155 -0
  46. data/lib/fluent/plugin/sd_static.rb +58 -0
  47. data/lib/fluent/plugin/service_discovery.rb +80 -0
  48. data/lib/fluent/plugin_helper.rb +1 -0
  49. data/lib/fluent/plugin_helper/child_process.rb +3 -3
  50. data/lib/fluent/plugin_helper/compat_parameters.rb +11 -1
  51. data/lib/fluent/plugin_helper/extract.rb +1 -1
  52. data/lib/fluent/plugin_helper/inject.rb +1 -1
  53. data/lib/fluent/plugin_helper/record_accessor.rb +10 -19
  54. data/lib/fluent/plugin_helper/server.rb +8 -4
  55. data/lib/fluent/plugin_helper/service_discovery.rb +80 -0
  56. data/lib/fluent/plugin_helper/service_discovery/manager.rb +132 -0
  57. data/lib/fluent/plugin_helper/service_discovery/round_robin_balancer.rb +43 -0
  58. data/lib/fluent/plugin_id.rb +7 -0
  59. data/lib/fluent/root_agent.rb +7 -9
  60. data/lib/fluent/supervisor.rb +192 -211
  61. data/lib/fluent/system_config.rb +26 -52
  62. data/lib/fluent/test/driver/base_owned.rb +15 -2
  63. data/lib/fluent/time.rb +8 -6
  64. data/lib/fluent/version.rb +1 -1
  65. data/test/command/test_fluentd.rb +12 -7
  66. data/test/config/test_configurable.rb +154 -0
  67. data/test/config/test_element.rb +18 -0
  68. data/test/config/test_literal_parser.rb +4 -0
  69. data/test/config/test_system_config.rb +48 -91
  70. data/test/config/test_types.rb +293 -120
  71. data/test/counter/test_client.rb +8 -4
  72. data/test/plugin/data/sd_file/config +11 -0
  73. data/test/plugin/data/sd_file/config.json +17 -0
  74. data/test/plugin/data/sd_file/config.yaml +11 -0
  75. data/test/plugin/data/sd_file/config.yml +11 -0
  76. data/test/plugin/data/sd_file/invalid_config.yml +7 -0
  77. data/test/plugin/out_forward/test_handshake_protocol.rb +2 -2
  78. data/test/plugin/out_forward/test_load_balancer.rb +1 -1
  79. data/test/plugin/out_forward/test_socket_cache.rb +2 -2
  80. data/test/plugin/test_buf_file.rb +40 -0
  81. data/test/plugin/test_buf_file_single.rb +32 -0
  82. data/test/plugin/test_buffer_file_chunk.rb +0 -11
  83. data/test/plugin/test_buffer_file_single_chunk.rb +0 -10
  84. data/test/plugin/test_formatter_csv.rb +9 -0
  85. data/test/plugin/test_in_forward.rb +9 -9
  86. data/test/plugin/test_in_monitor_agent.rb +37 -10
  87. data/test/plugin/test_in_unix.rb +5 -5
  88. data/test/plugin/test_out_forward.rb +45 -1
  89. data/test/plugin/test_out_stdout.rb +36 -1
  90. data/test/plugin/test_out_stream.rb +3 -3
  91. data/test/plugin/test_output.rb +25 -1
  92. data/test/plugin/test_sd_file.rb +211 -0
  93. data/test/plugin_helper/service_discovery/test_manager.rb +93 -0
  94. data/test/plugin_helper/service_discovery/test_round_robin_balancer.rb +21 -0
  95. data/test/plugin_helper/test_server.rb +13 -0
  96. data/test/plugin_helper/test_service_discovery.rb +72 -0
  97. data/test/test_event.rb +15 -15
  98. data/test/test_fluent_log_event_router.rb +99 -0
  99. data/test/test_logger_initializer.rb +26 -0
  100. data/test/test_supervisor.rb +30 -59
  101. metadata +43 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ac4a6f9d933f5ab055685ea55073ed2075774fcfd06e9d6caa83173fa54bf6a
4
- data.tar.gz: a6c1591f5668ccfeebbe94f74bed82359cd968011f65c8fae4707f912f09bab7
3
+ metadata.gz: fc4b25e6ef17858140851741cb1393cea6c9735d70df0ebf3dc5d56b4d09889d
4
+ data.tar.gz: 173a01d0e1315d960815dedfdd959e95122e76bd63b941f25856e3a06784e336
5
5
  SHA512:
6
- metadata.gz: 31211269e644bfbfa87535d431c3ee62fe76b67e38c2ed34cc2d76b08849db974b1c940e2dd100f01c18506db63cae8cf6822b7a16191ea019d6f4b408c54ce3
7
- data.tar.gz: 9b6671277290439f1711de19b1e5634978b285a9392dbeb739e47f6acee296466defac66e4e5b7b60032703821125c0c094f3b9be181209c2cec34dd01afbdf4
6
+ metadata.gz: 5be24749486ea83e7de373a04bdb4da3c6d85b87384dc1c2b36c8d506f43f5b6308fb3b9adafca8fd13152220bed2f3bddb366996713abaf7156e9b2a5f412b8
7
+ data.tar.gz: 85a744dafbd03254f6b889164cc58ffec01380182b9745199e1ed0c7afaeefa160bf7e15eeeda7bacf7d215eff62be0f1802e9d223464a59ee5bf98753a3b546
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  name: Bug Report
3
3
  about: Create a report to help us improve. If you have questions about Fluentd and plugins, please direct these to https://groups.google.com/forum/#!forum/fluentd
4
- labels: 'bug'
5
4
 
6
5
  ---
7
6
 
@@ -49,6 +49,10 @@ matrix:
49
49
  - rvm: 2.4.6
50
50
  os: osx
51
51
  osx_image: xcode8.3
52
+ - rvm: 2.5.5
53
+ os: linux
54
+ arch: s390x
55
+ dist: xenial
52
56
  - rvm: ruby-head
53
57
 
54
58
  branches:
@@ -1,3 +1,73 @@
1
+ # v1.8
2
+
3
+ ## Release v1.8.0 - 2019/12/11
4
+
5
+ ### New feature
6
+
7
+ * Add service discovery plugin and `out_forward` use it
8
+ https://github.com/fluent/fluentd/pull/2541
9
+ * config: Add strict mode and support `default`/`nil` value in ruby embedded mode
10
+ https://github.com/fluent/fluentd/pull/2685
11
+
12
+ ### Enhancement
13
+
14
+ * formatter_csv: Support nested fields
15
+ https://github.com/fluent/fluentd/pull/2643
16
+ * record_accessor helper: Make code simple and bit faster
17
+ https://github.com/fluent/fluentd/pull/2660
18
+ * Relax tzinfo dependency to accept v1
19
+ https://github.com/fluent/fluentd/pull/2673
20
+ * log: Deprecate top-level match for capturing fluentd logs
21
+ https://github.com/fluent/fluentd/pull/2689
22
+ * in_monitor_agent: Expose Fluentd verion in REST API
23
+ https://github.com/fluent/fluentd/pull/2706
24
+ * time: Accept localtime xor utc
25
+ https://github.com/fluent/fluentd/pull/2720
26
+ https://github.com/fluent/fluentd/pull/2731
27
+ * formatter_stdout: Make time_format configurable in stdout format
28
+ https://github.com/fluent/fluentd/pull/2721
29
+ * supervisor: create log directory when it doesn't exists
30
+ https://github.com/fluent/fluentd/pull/2732
31
+ * clean up internal classes / methods / code
32
+ https://github.com/fluent/fluentd/pull/2647
33
+ https://github.com/fluent/fluentd/pull/2648
34
+ https://github.com/fluent/fluentd/pull/2653
35
+ https://github.com/fluent/fluentd/pull/2654
36
+ https://github.com/fluent/fluentd/pull/2657
37
+ https://github.com/fluent/fluentd/pull/2667
38
+ https://github.com/fluent/fluentd/pull/2674
39
+ https://github.com/fluent/fluentd/pull/2677
40
+ https://github.com/fluent/fluentd/pull/2680
41
+ https://github.com/fluent/fluentd/pull/2709
42
+ https://github.com/fluent/fluentd/pull/2730
43
+
44
+ ### Bug fixes
45
+
46
+ * output: Fix warning printed when chunk key placeholder not replaced
47
+ https://github.com/fluent/fluentd/pull/2523
48
+ https://github.com/fluent/fluentd/pull/2733
49
+ * Fix dry-run mode
50
+ https://github.com/fluent/fluentd/pull/2651
51
+ * suppress warning
52
+ https://github.com/fluent/fluentd/pull/2652
53
+ * suppress keyword argument warning for ruby2.7
54
+ https://github.com/fluent/fluentd/pull/2664
55
+ * RPC: Fix debug log text
56
+ https://github.com/fluent/fluentd/pull/2666
57
+ * time: Properly show class names in error message
58
+ https://github.com/fluent/fluentd/pull/2671
59
+ * Fix a potential bug that ThreadError may occur on SIGUSR1
60
+ https://github.com/fluent/fluentd/pull/2678
61
+ * server helper: Ignore ECONNREFUSED in TLS accept to avoid fluentd restart
62
+ https://github.com/fluent/fluentd/pull/2695
63
+ * server helper: Fix IPv6 dual stack mode issue for tcp socket.
64
+ https://github.com/fluent/fluentd/pull/2697
65
+ * supervisor: Fix inline config handling
66
+ https://github.com/fluent/fluentd/pull/2708
67
+ * Fix typo
68
+ https://github.com/fluent/fluentd/pull/2710
69
+ https://github.com/fluent/fluentd/pull/2714
70
+
1
71
  # v1.7
2
72
 
3
73
  ## Release v1.7.4 - 2019/10/24
@@ -5,3 +5,4 @@
5
5
  - [Hiroshi Hatake](https://github.com/cosmo0920), [Clearcode](https://www.clear-code.com/)
6
6
  - [Masahiro Nakagawa](https://github.com/repeatedly), [Treasure Data](https://www.treasuredata.com/)
7
7
  - [Satoshi Tagomori](https://github.com/tagomoris), [Treasure Data](https://www.treasuredata.com/)
8
+ - [Eduardo Silva](https://github.com/edsiper), [Arm Treasure Data](https://www.treasuredata.com/)
@@ -0,0 +1,17 @@
1
+ <source>
2
+ @type dummy
3
+ tag test
4
+ </source>
5
+
6
+ <match test>
7
+ @type forward
8
+
9
+ <service_discovery>
10
+ @type file
11
+ path "#{Dir.pwd}/example/sd.yaml"
12
+ </service_discovery>
13
+
14
+ <buffer>
15
+ flush_interval 1
16
+ </buffer>
17
+ </match>
@@ -0,0 +1,8 @@
1
+ - 'host': 127.0.0.1
2
+ 'port': 24224
3
+ 'weight': 1
4
+ 'name': server1
5
+ - 'host': 127.0.0.1
6
+ 'port': 24225
7
+ 'weight': 1
8
+ 'name': server2
@@ -24,7 +24,7 @@ Gem::Specification.new do |gem|
24
24
  gem.add_runtime_dependency("serverengine", [">= 2.0.4", "< 3.0.0"])
25
25
  gem.add_runtime_dependency("http_parser.rb", [">= 0.5.1", "< 0.7.0"])
26
26
  gem.add_runtime_dependency("sigdump", ["~> 0.2.2"])
27
- gem.add_runtime_dependency("tzinfo", ["~> 2.0"])
27
+ gem.add_runtime_dependency("tzinfo", [">= 1.0", "< 3.0"])
28
28
  gem.add_runtime_dependency("tzinfo-data", ["~> 1.0"])
29
29
  gem.add_runtime_dependency("strptime", [">= 0.2.2", "< 1.0.0"])
30
30
  gem.add_runtime_dependency("dig_rb", ["~> 1.0.0"])
@@ -62,7 +62,9 @@ module Fluent
62
62
 
63
63
  # initialize <match> and <filter> elements
64
64
  conf.elements('filter', 'match').each { |e|
65
- next if e.for_another_worker?
65
+ if !Fluent::Engine.supervisor_mode && e.for_another_worker?
66
+ next
67
+ end
66
68
  pattern = e.arg.empty? ? '**' : e.arg
67
69
  type = e['@type']
68
70
  raise ConfigError, "Missing '@type' parameter on <#{e.name}> directive" unless type
@@ -315,7 +315,7 @@ when 'msgpack'
315
315
  require 'fluent/engine'
316
316
 
317
317
  begin
318
- u = Fluent::Engine.msgpack_factory.unpacker($stdin)
318
+ u = Fluent::MessagePackFactory.msgpack_unpacker($stdin)
319
319
  u.each {|record|
320
320
  w.write(record)
321
321
  }
@@ -340,4 +340,3 @@ else
340
340
  $stderr.puts "Unknown format '#{format}'"
341
341
  exit 1
342
342
  end
343
-
@@ -131,6 +131,10 @@ op.on('--use-v0-config', "Use v0 configuration format", TrueClass) {|b|
131
131
  opts[:use_v1_config] = !b
132
132
  }
133
133
 
134
+ op.on('--strict-config-value', "Parse config values strictly", TrueClass) {|b|
135
+ opts[:strict_config_value] = b
136
+ }
137
+
134
138
  op.on('-v', '--verbose', "increase verbose level (-v: debug, -vv: trace)", TrueClass) {|b|
135
139
  if b
136
140
  opts[:log_level] = [opts[:log_level] - 1, Fluent::Log::LEVEL_TRACE].max
@@ -162,7 +166,7 @@ op.on('--conf-encoding ENCODING', "specify configuration file encoding") { |s|
162
166
  if Fluent.windows?
163
167
  require 'windows/library'
164
168
  include Windows::Library
165
-
169
+
166
170
  opts.merge!(
167
171
  :winsvc_name => 'fluentdwinsvc',
168
172
  :winsvc_display_name => 'Fluentd Windows Service',
@@ -184,15 +188,15 @@ if Fluent.windows?
184
188
  op.on('--reg-winsvc-fluentdopt OPTION', "specify fluentd option parameters for Windows Service. (Windows only)") {|s|
185
189
  opts[:fluentdopt] = s
186
190
  }
187
-
191
+
188
192
  op.on('--winsvc-name NAME', "The Windows Service name to run as (Windows only)") {|s|
189
193
  opts[:winsvc_name] = s
190
194
  }
191
-
195
+
192
196
  op.on('--winsvc-display-name DISPLAY_NAME', "The Windows Service display name (Windows only)") {|s|
193
197
  opts[:winsvc_display_name] = s
194
198
  }
195
-
199
+
196
200
  op.on('--winsvc-desc DESC', "The Windows Service description (Windows only)") {|s|
197
201
  opts[:winsvc_desc] = s
198
202
  }
@@ -268,7 +272,7 @@ if winsvcinstmode = opts[:regwinsvc]
268
272
  start_service = true
269
273
  end
270
274
 
271
-
275
+
272
276
  Service.create(
273
277
  service_name: opts[:winsvc_name],
274
278
  host: nil,
@@ -309,7 +313,6 @@ end
309
313
 
310
314
  exit 0 if early_exit
311
315
 
312
- require 'fluent/supervisor'
313
316
  if opts[:supervise]
314
317
  if Fluent.windows?
315
318
  if opts[:log_path] && opts[:log_path] != "-"
@@ -321,11 +324,16 @@ if opts[:supervise]
321
324
  end
322
325
  end
323
326
  end
324
- Fluent::Supervisor.new(opts).run_supervisor
327
+
328
+ supervisor = Fluent::Supervisor.new(opts)
329
+ supervisor.configure(supervisor: true)
330
+ supervisor.run_supervisor(dry_run: opts[:dry_run])
325
331
  else
326
332
  if opts[:standalone_worker] && opts[:workers] && opts[:workers] > 1
327
333
  puts "Error: multi workers is not supported with --no-supervisor"
328
334
  exit 2
329
335
  end
330
- Fluent::Supervisor.new(opts).run_worker
336
+ worker = Fluent::Supervisor.new(opts)
337
+ worker.configure
338
+ worker.run_worker
331
339
  end
@@ -55,6 +55,15 @@ module Fluent
55
55
  end
56
56
  end
57
57
 
58
+ def stop
59
+ klass = self.class
60
+ @@_super_start.delete(klass)
61
+ @@_super_before_shutdown.delete(klass)
62
+ @@_super_shutdown.delete(klass)
63
+
64
+ super
65
+ end
66
+
58
67
  def shutdown
59
68
  super
60
69
  unless self.shutdown?
@@ -85,7 +85,7 @@ module Fluent
85
85
 
86
86
  class MessagePackParser < Parser
87
87
  def call(io)
88
- @u = Fluent::Engine.msgpack_factory.unpacker(io)
88
+ @u = Fluent::MessagePackFactory.msgpack_unpacker(io)
89
89
  begin
90
90
  @u.each(&@on_message)
91
91
  rescue EOFError
@@ -117,9 +117,9 @@ module Fluent
117
117
 
118
118
  merged = if self.root?
119
119
  options[:root] = true
120
- self.class.new(other.name, options)
120
+ self.class.new(other.name, **options)
121
121
  else
122
- self.class.new(@name, options)
122
+ self.class.new(@name, **options)
123
123
  end
124
124
 
125
125
  # configured_in MUST be kept
@@ -172,9 +172,9 @@ module Fluent
172
172
 
173
173
  merged = if self.root?
174
174
  options[:root] = true
175
- self.class.new(other.name, options)
175
+ self.class.new(other.name, **options)
176
176
  else
177
- self.class.new(@name, options)
177
+ self.class.new(@name, **options)
178
178
  end
179
179
 
180
180
  merged.configured_in_section = self.configured_in_section || other.configured_in_section
@@ -142,7 +142,7 @@ module Fluent
142
142
  indent = " " * nest
143
143
  nindent = " " * (nest + 1)
144
144
  out = ""
145
- if @arg.empty?
145
+ if @arg.nil? || @arg.empty?
146
146
  out << "#{indent}<#{@name}>\n"
147
147
  else
148
148
  out << "#{indent}<#{@name} #{@arg}>\n"
@@ -194,23 +194,36 @@ module Fluent
194
194
  opts[:type]
195
195
  end
196
196
 
197
+ def default_value(key)
198
+ return nil if @corresponding_proxies.empty?
199
+
200
+ param_key = key.to_sym
201
+ proxy = @corresponding_proxies.detect do |_proxy|
202
+ _proxy.params.has_key?(param_key)
203
+ end
204
+ return nil unless proxy
205
+ proxy.defaults[param_key]
206
+ end
207
+
197
208
  def dump_value(k, v, nindent)
198
- if secret_param?(k)
199
- "#{nindent}#{k} xxxxxx\n"
209
+ return "#{nindent}#{k} xxxxxx\n" if secret_param?(k)
210
+ return "#{nindent}#{k} #{v}\n" unless @v1_config
211
+
212
+ # for v1 config
213
+ if v.nil?
214
+ "#{nindent}#{k} \n"
215
+ elsif v == :default
216
+ "#{nindent}#{k} #{default_value(k)}\n"
200
217
  else
201
- if @v1_config
202
- case param_type(k)
203
- when :string
204
- "#{nindent}#{k} \"#{self.class.unescape_parameter(v)}\"\n"
205
- when :enum, :integer, :float, :size, :bool, :time
206
- "#{nindent}#{k} #{v}\n"
207
- when :hash, :array
208
- "#{nindent}#{k} #{v}\n"
209
- else
210
- # Unknown type
211
- "#{nindent}#{k} #{v}\n"
212
- end
218
+ case param_type(k)
219
+ when :string
220
+ "#{nindent}#{k} \"#{self.class.unescape_parameter(v)}\"\n"
221
+ when :enum, :integer, :float, :size, :bool, :time
222
+ "#{nindent}#{k} #{v}\n"
223
+ when :hash, :array
224
+ "#{nindent}#{k} #{v}\n"
213
225
  else
226
+ # Unknown type
214
227
  "#{nindent}#{k} #{v}\n"
215
228
  end
216
229
  end
@@ -23,4 +23,10 @@ module Fluent
23
23
 
24
24
  class ObsoletedParameterError < ConfigError
25
25
  end
26
+
27
+ class SetNil < Exception
28
+ end
29
+
30
+ class SetDefault < Exception
31
+ end
26
32
  end
@@ -52,6 +52,16 @@ module Fluent
52
52
  def initialize(strscan, eval_context)
53
53
  super(strscan)
54
54
  @eval_context = eval_context
55
+ unless @eval_context.respond_to?(:use_nil)
56
+ def @eval_context.use_nil
57
+ raise SetNil
58
+ end
59
+ end
60
+ unless @eval_context.respond_to?(:use_default)
61
+ def @eval_context.use_default
62
+ raise SetDefault
63
+ end
64
+ end
55
65
  end
56
66
 
57
67
  def parse_literal(string_boundary_charset = LINE_END)
@@ -81,7 +91,13 @@ module Fluent
81
91
  string = []
82
92
  while true
83
93
  if skip(/\"/)
84
- return string.join
94
+ if string.include?(nil)
95
+ return nil
96
+ elsif string.include?(:default)
97
+ return :default
98
+ else
99
+ return string.join
100
+ end
85
101
  elsif check(/[^"]#{LINE_END_WITHOUT_SPACING_AND_COMMENT}/)
86
102
  if s = check(/[^\\]#{LINE_END_WITHOUT_SPACING_AND_COMMENT}/)
87
103
  string << s
@@ -168,7 +184,13 @@ module Fluent
168
184
  hostname = Socket.gethostname
169
185
  worker_id = ENV['SERVERENGINE_WORKER_ID'] || ''
170
186
  EOM
171
- @eval_context.instance_eval(code)
187
+ begin
188
+ @eval_context.instance_eval(code)
189
+ rescue SetNil => e
190
+ nil
191
+ rescue SetDefault => e
192
+ :default
193
+ end
172
194
  end
173
195
 
174
196
  def eval_escape_char(c)
@@ -106,7 +106,7 @@ module Fluent
106
106
  end
107
107
 
108
108
  module SectionGenerator
109
- def self.generate(proxy, conf, logger, plugin_class, stack = [])
109
+ def self.generate(proxy, conf, logger, plugin_class, stack = [], strict_config_value = false)
110
110
  return nil if conf.nil?
111
111
 
112
112
  section_stack = ""
@@ -122,9 +122,23 @@ module Fluent
122
122
  end
123
123
 
124
124
  if proxy.argument
125
- unless conf.arg.empty?
125
+ unless conf.arg.nil? || conf.arg.empty?
126
126
  key, block, opts = proxy.argument
127
- section_params[key] = self.instance_exec(conf.arg, opts, name, &block)
127
+ opts = opts.merge(strict: true) if strict_config_value
128
+
129
+ if conf.arg == :default
130
+ unless section_params.has_key?(key)
131
+ logger.error "config error in:\n#{conf}" if logger
132
+ raise ConfigError, "'#{key}' doesn't have default value"
133
+ end
134
+ else
135
+ begin
136
+ section_params[key] = self.instance_exec(conf.arg, opts, key, &block)
137
+ rescue ConfigError => e
138
+ logger.error "config error in:\n#{conf}" if logger
139
+ raise e
140
+ end
141
+ end
128
142
  end
129
143
  unless section_params.has_key?(proxy.argument.first)
130
144
  logger.error "config error in:\n#{conf}" if logger # logger should exist, but somethimes it's nil (e.g, in tests)
@@ -136,13 +150,36 @@ module Fluent
136
150
  proxy.params.each_pair do |name, defval|
137
151
  varname = name.to_sym
138
152
  block, opts = defval
153
+ opts = opts.merge(strict: true) if strict_config_value
154
+
139
155
  if conf.has_key?(name.to_s) || opts[:alias] && conf.has_key?(opts[:alias].to_s)
140
156
  val = if conf.has_key?(name.to_s)
141
157
  conf[name.to_s]
142
158
  else
143
159
  conf[opts[:alias].to_s]
144
160
  end
145
- section_params[varname] = self.instance_exec(val, opts, name, &block)
161
+
162
+ if val == :default
163
+ # default value is already set if it exists
164
+ unless section_params.has_key?(varname)
165
+ logger.error "config error in:\n#{conf}" if logger
166
+ raise ConfigError, "'#{varname}' doesn't have default value"
167
+ end
168
+ else
169
+ begin
170
+ section_params[varname] = self.instance_exec(val, opts, name, &block)
171
+ rescue ConfigError => e
172
+ logger.error "config error in:\n#{conf}" if logger
173
+ raise e
174
+ end
175
+ end
176
+
177
+ if section_params[varname].nil?
178
+ unless proxy.defaults.has_key?(varname) and proxy.defaults[varname].nil?
179
+ logger.error "config error in:\n#{conf}" if logger
180
+ raise ConfigError, "'#{name}' parameter is required but nil is specified"
181
+ end
182
+ end
146
183
 
147
184
  # Source of definitions of deprecated/obsoleted:
148
185
  # https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features
@@ -190,13 +227,13 @@ module Fluent
190
227
  raise ConfigError, "'<#{subproxy.name}>' sections are required" + section_stack
191
228
  end
192
229
  if subproxy.multi?
193
- section_params[varname] = elements.map{ |e| generate(subproxy, e, logger, plugin_class, stack + [subproxy.name]) }
230
+ section_params[varname] = elements.map{ |e| generate(subproxy, e, logger, plugin_class, stack + [subproxy.name], strict_config_value) }
194
231
  else
195
232
  if elements.size > 1
196
233
  logger.error "config error in:\n#{conf}" if logger
197
234
  raise ConfigError, "'<#{subproxy.name}>' section cannot be written twice or more" + section_stack
198
235
  end
199
- section_params[varname] = generate(subproxy, elements.first, logger, plugin_class, stack + [subproxy.name])
236
+ section_params[varname] = generate(subproxy, elements.first, logger, plugin_class, stack + [subproxy.name], strict_config_value)
200
237
  end
201
238
  end
202
239