fluentd 1.7.4-x86-mingw32 → 1.8.0-x86-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.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -1
- data/.travis.yml +4 -0
- data/CHANGELOG.md +70 -0
- data/MAINTAINERS.md +1 -0
- data/example/out_forward_sd.conf +17 -0
- data/example/sd.yaml +8 -0
- data/fluentd.gemspec +1 -1
- data/lib/fluent/agent.rb +3 -1
- data/lib/fluent/command/cat.rb +1 -2
- data/lib/fluent/command/fluentd.rb +16 -8
- data/lib/fluent/compat/call_super_mixin.rb +9 -0
- data/lib/fluent/compat/exec_util.rb +1 -1
- data/lib/fluent/config/configure_proxy.rb +4 -4
- data/lib/fluent/config/element.rb +28 -15
- data/lib/fluent/config/error.rb +6 -0
- data/lib/fluent/config/literal_parser.rb +24 -2
- data/lib/fluent/config/section.rb +43 -6
- data/lib/fluent/config/types.rb +98 -26
- data/lib/fluent/configurable.rb +2 -2
- data/lib/fluent/counter/base_socket.rb +2 -4
- data/lib/fluent/engine.rb +41 -122
- data/lib/fluent/event.rb +5 -7
- data/lib/fluent/fluent_log_event_router.rb +141 -0
- data/lib/fluent/msgpack_factory.rb +19 -2
- data/lib/fluent/plugin.rb +10 -1
- data/lib/fluent/plugin/base.rb +2 -2
- data/lib/fluent/plugin/buf_file.rb +11 -7
- data/lib/fluent/plugin/buf_file_single.rb +8 -5
- data/lib/fluent/plugin/buffer/chunk.rb +1 -1
- data/lib/fluent/plugin/buffer/file_chunk.rb +4 -6
- data/lib/fluent/plugin/buffer/file_single_chunk.rb +3 -5
- data/lib/fluent/plugin/formatter_csv.rb +23 -1
- data/lib/fluent/plugin/formatter_stdout.rb +1 -1
- data/lib/fluent/plugin/in_forward.rb +1 -1
- data/lib/fluent/plugin/in_monitor_agent.rb +4 -2
- data/lib/fluent/plugin/in_tail.rb +6 -0
- data/lib/fluent/plugin/in_unix.rb +1 -1
- data/lib/fluent/plugin/out_forward.rb +77 -28
- data/lib/fluent/plugin/out_forward/ack_handler.rb +1 -1
- data/lib/fluent/plugin/out_forward/load_balancer.rb +5 -2
- data/lib/fluent/plugin/out_stream.rb +1 -1
- data/lib/fluent/plugin/output.rb +11 -3
- data/lib/fluent/plugin/parser.rb +1 -0
- data/lib/fluent/plugin/sd_file.rb +155 -0
- data/lib/fluent/plugin/sd_static.rb +58 -0
- data/lib/fluent/plugin/service_discovery.rb +80 -0
- data/lib/fluent/plugin_helper.rb +1 -0
- data/lib/fluent/plugin_helper/child_process.rb +3 -3
- data/lib/fluent/plugin_helper/compat_parameters.rb +11 -1
- data/lib/fluent/plugin_helper/extract.rb +1 -1
- data/lib/fluent/plugin_helper/inject.rb +1 -1
- data/lib/fluent/plugin_helper/record_accessor.rb +10 -19
- data/lib/fluent/plugin_helper/server.rb +8 -4
- data/lib/fluent/plugin_helper/service_discovery.rb +80 -0
- data/lib/fluent/plugin_helper/service_discovery/manager.rb +132 -0
- data/lib/fluent/plugin_helper/service_discovery/round_robin_balancer.rb +43 -0
- data/lib/fluent/plugin_id.rb +7 -0
- data/lib/fluent/root_agent.rb +7 -9
- data/lib/fluent/supervisor.rb +192 -211
- data/lib/fluent/system_config.rb +26 -52
- data/lib/fluent/test/driver/base_owned.rb +15 -2
- data/lib/fluent/time.rb +8 -6
- data/lib/fluent/version.rb +1 -1
- data/test/command/test_fluentd.rb +12 -7
- data/test/config/test_configurable.rb +154 -0
- data/test/config/test_element.rb +18 -0
- data/test/config/test_literal_parser.rb +4 -0
- data/test/config/test_system_config.rb +48 -91
- data/test/config/test_types.rb +293 -120
- data/test/counter/test_client.rb +8 -4
- data/test/plugin/data/sd_file/config +11 -0
- data/test/plugin/data/sd_file/config.json +17 -0
- data/test/plugin/data/sd_file/config.yaml +11 -0
- data/test/plugin/data/sd_file/config.yml +11 -0
- data/test/plugin/data/sd_file/invalid_config.yml +7 -0
- data/test/plugin/out_forward/test_handshake_protocol.rb +2 -2
- data/test/plugin/out_forward/test_load_balancer.rb +1 -1
- data/test/plugin/out_forward/test_socket_cache.rb +2 -2
- data/test/plugin/test_buf_file.rb +40 -0
- data/test/plugin/test_buf_file_single.rb +32 -0
- data/test/plugin/test_buffer_file_chunk.rb +0 -11
- data/test/plugin/test_buffer_file_single_chunk.rb +0 -10
- data/test/plugin/test_formatter_csv.rb +9 -0
- data/test/plugin/test_in_forward.rb +9 -9
- data/test/plugin/test_in_monitor_agent.rb +37 -10
- data/test/plugin/test_in_unix.rb +5 -5
- data/test/plugin/test_out_forward.rb +45 -1
- data/test/plugin/test_out_stdout.rb +36 -1
- data/test/plugin/test_out_stream.rb +3 -3
- data/test/plugin/test_output.rb +25 -1
- data/test/plugin/test_sd_file.rb +211 -0
- data/test/plugin_helper/service_discovery/test_manager.rb +93 -0
- data/test/plugin_helper/service_discovery/test_round_robin_balancer.rb +21 -0
- data/test/plugin_helper/test_server.rb +13 -0
- data/test/plugin_helper/test_service_discovery.rb +72 -0
- data/test/test_event.rb +15 -15
- data/test/test_fluent_log_event_router.rb +99 -0
- data/test/test_logger_initializer.rb +26 -0
- data/test/test_supervisor.rb +30 -59
- metadata +43 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f11b6916f42b90ca76bc75b947cb1db9e31ac751c8131eef61ac60831eca3e2
|
4
|
+
data.tar.gz: eaf87bd31428b152df97b559d2464c7cdee401844ba3abb50fc8bfe11427f857
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74a3268e64122bca27ec100cf7f901b0bf8a582463a2f5e717d89556e14270e4a933c44e11b3e7551a7dca48b66ee47f3ce7a4482fb8d819462eaeb167f6036b
|
7
|
+
data.tar.gz: f8fb1269fab2bf710deede52f1609670e9b708769d18a5d7473ba42eb6e5fa9fed4d492ba052916339313822975f853136ee2b92aa1a9dd3cc6830b8152f3132
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -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
|
data/MAINTAINERS.md
CHANGED
@@ -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/)
|
data/example/sd.yaml
ADDED
data/fluentd.gemspec
CHANGED
@@ -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", ["
|
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"])
|
data/lib/fluent/agent.rb
CHANGED
@@ -62,7 +62,9 @@ module Fluent
|
|
62
62
|
|
63
63
|
# initialize <match> and <filter> elements
|
64
64
|
conf.elements('filter', 'match').each { |e|
|
65
|
-
|
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
|
data/lib/fluent/command/cat.rb
CHANGED
@@ -315,7 +315,7 @@ when 'msgpack'
|
|
315
315
|
require 'fluent/engine'
|
316
316
|
|
317
317
|
begin
|
318
|
-
u = Fluent::
|
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
|
-
|
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)
|
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?
|
@@ -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
|
-
|
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
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
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
|
data/lib/fluent/config/error.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
|