fluentd 0.12.0.pre.2 → 0.12.0.pre.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.
- checksums.yaml +4 -4
- data/example/v0_12_filter.conf +78 -0
- data/fluentd.gemspec +2 -1
- data/lib/fluent/agent.rb +2 -1
- data/lib/fluent/buffer.rb +9 -5
- data/lib/fluent/command/fluentd.rb +4 -0
- data/lib/fluent/config/basic_parser.rb +1 -0
- data/lib/fluent/config/configure_proxy.rb +7 -7
- data/lib/fluent/config/types.rb +1 -0
- data/lib/fluent/config/v1_parser.rb +1 -1
- data/lib/fluent/engine.rb +0 -25
- data/lib/fluent/env.rb +1 -0
- data/lib/fluent/event_router.rb +6 -2
- data/lib/fluent/filter.rb +12 -1
- data/lib/fluent/formatter.rb +85 -16
- data/lib/fluent/label.rb +4 -0
- data/lib/fluent/output.rb +1 -0
- data/lib/fluent/parser.rb +25 -23
- data/lib/fluent/plugin.rb +18 -0
- data/lib/fluent/plugin/buf_file.rb +1 -1
- data/lib/fluent/plugin/in_dummy.rb +103 -0
- data/lib/fluent/plugin/in_http.rb +30 -10
- data/lib/fluent/plugin/in_syslog.rb +4 -4
- data/lib/fluent/plugin/in_tail.rb +6 -6
- data/lib/fluent/plugin/out_file.rb +3 -3
- data/lib/fluent/plugin/socket_util.rb +2 -2
- data/lib/fluent/registry.rb +9 -27
- data/lib/fluent/root_agent.rb +26 -7
- data/lib/fluent/supervisor.rb +40 -27
- data/lib/fluent/test.rb +1 -0
- data/lib/fluent/test/base.rb +14 -0
- data/lib/fluent/test/filter_test.rb +33 -0
- data/lib/fluent/test/output_test.rb +7 -1
- data/lib/fluent/version.rb +1 -1
- data/test/config/test_config_parser.rb +6 -2
- data/test/config/test_configurable.rb +1 -1
- data/test/config/test_configure_proxy.rb +1 -1
- data/test/config/test_dsl.rb +1 -1
- data/test/config/test_literal_parser.rb +2 -2
- data/test/config/test_section.rb +1 -1
- data/test/config/test_system_config.rb +65 -15
- data/test/config/test_types.rb +63 -0
- data/test/helper.rb +2 -1
- data/test/plugin/test_buf_file.rb +1 -1
- data/test/plugin/test_buf_memory.rb +1 -1
- data/test/plugin/test_filter_grep.rb +17 -23
- data/test/plugin/test_filter_record_transformer.rb +18 -21
- data/test/plugin/test_in_dummy.rb +95 -0
- data/test/plugin/test_in_exec.rb +1 -1
- data/test/plugin/test_in_forward.rb +1 -1
- data/test/plugin/test_in_gc_stat.rb +1 -1
- data/test/plugin/test_in_http.rb +1 -1
- data/test/plugin/test_in_object_space.rb +1 -1
- data/test/plugin/test_in_status.rb +1 -1
- data/test/plugin/test_in_stream.rb +1 -1
- data/test/plugin/test_in_syslog.rb +1 -1
- data/test/plugin/test_in_tail.rb +1 -1
- data/test/plugin/test_in_tcp.rb +1 -1
- data/test/plugin/test_in_udp.rb +1 -1
- data/test/plugin/test_out_copy.rb +12 -1
- data/test/plugin/test_out_exec.rb +1 -1
- data/test/plugin/test_out_exec_filter.rb +1 -1
- data/test/plugin/test_out_file.rb +61 -8
- data/test/plugin/test_out_forward.rb +1 -1
- data/test/plugin/test_out_roundrobin.rb +12 -1
- data/test/plugin/test_out_stdout.rb +1 -1
- data/test/plugin/test_out_stream.rb +1 -1
- data/test/scripts/fluent/plugin/formatter_known.rb +4 -1
- data/{lib → test/scripts}/fluent/plugin/out_test.rb +0 -0
- data/test/scripts/fluent/plugin/parser_known.rb +2 -1
- data/test/test_buffer.rb +1 -1
- data/test/test_config.rb +1 -1
- data/test/test_configdsl.rb +1 -1
- data/test/test_event_router.rb +233 -0
- data/test/test_formatter.rb +160 -3
- data/test/test_input.rb +30 -0
- data/test/test_match.rb +100 -77
- data/test/test_mixin.rb +1 -1
- data/test/test_output.rb +1 -1
- data/test/test_parser.rb +5 -3
- data/test/test_plugin_classes.rb +60 -0
- metadata +32 -4
@@ -104,7 +104,7 @@ module Fluent
|
|
104
104
|
def configure(conf)
|
105
105
|
super
|
106
106
|
|
107
|
-
@parser =
|
107
|
+
@parser = Plugin.new_parser(@format)
|
108
108
|
@parser.configure(conf)
|
109
109
|
end
|
110
110
|
|
@@ -132,7 +132,7 @@ module Fluent
|
|
132
132
|
private
|
133
133
|
|
134
134
|
def on_message(msg, addr)
|
135
|
-
@parser.
|
135
|
+
@parser.call(msg) { |time, record|
|
136
136
|
unless time && record
|
137
137
|
log.warn "pattern not match: #{msg.inspect}"
|
138
138
|
return
|
data/lib/fluent/registry.rb
CHANGED
@@ -57,34 +57,16 @@ module Fluent
|
|
57
57
|
return
|
58
58
|
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
spec.contains_requirable_file? path
|
64
|
-
}
|
65
|
-
|
66
|
-
# prefer newer version
|
67
|
-
specs = specs.sort_by { |spec| spec.version }
|
68
|
-
if spec = specs.last
|
69
|
-
spec.require_paths.each { |lib|
|
70
|
-
file = "#{spec.full_gem_path}/#{lib}/#{path}"
|
71
|
-
require file
|
72
|
-
}
|
73
|
-
end
|
60
|
+
specs = Gem::Specification.find_all { |spec|
|
61
|
+
spec.contains_requirable_file? path
|
62
|
+
}
|
74
63
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
specs = specs.sort_by { |spec| spec.version }
|
82
|
-
specs.reverse_each { |spec|
|
83
|
-
files = Gem.searcher.matching_files(spec, path)
|
84
|
-
unless files.empty?
|
85
|
-
require files.first
|
86
|
-
break
|
87
|
-
end
|
64
|
+
# prefer newer version
|
65
|
+
specs = specs.sort_by { |spec| spec.version }
|
66
|
+
if spec = specs.last
|
67
|
+
spec.require_paths.each { |lib|
|
68
|
+
file = "#{spec.full_gem_path}/#{lib}/#{path}"
|
69
|
+
require file
|
88
70
|
}
|
89
71
|
end
|
90
72
|
end
|
data/lib/fluent/root_agent.rb
CHANGED
@@ -73,7 +73,7 @@ module Fluent
|
|
73
73
|
if name == ERROR_LABEL
|
74
74
|
error_label_config = e
|
75
75
|
else
|
76
|
-
add_label(name
|
76
|
+
add_label(name)
|
77
77
|
label_configs[name] = e
|
78
78
|
end
|
79
79
|
}
|
@@ -96,7 +96,7 @@ module Fluent
|
|
96
96
|
|
97
97
|
def setup_error_label(e)
|
98
98
|
# initialize built-in ERROR label
|
99
|
-
error_label = add_label(ERROR_LABEL
|
99
|
+
error_label = add_label(ERROR_LABEL)
|
100
100
|
error_label.configure(e)
|
101
101
|
error_label.root_agent = RootAgentProxyWithoutErrorCollector.new(self)
|
102
102
|
@error_collector = error_label.event_router
|
@@ -154,7 +154,7 @@ module Fluent
|
|
154
154
|
input
|
155
155
|
end
|
156
156
|
|
157
|
-
def add_label(name
|
157
|
+
def add_label(name)
|
158
158
|
label = Label.new(name)
|
159
159
|
label.root_agent = self
|
160
160
|
@labels[name] = label
|
@@ -168,20 +168,34 @@ module Fluent
|
|
168
168
|
end
|
169
169
|
end
|
170
170
|
|
171
|
-
def
|
171
|
+
def emit_error_event(tag, time, record, error)
|
172
|
+
error_info = {:error_class => error.class, :error => error.to_s, :tag => tag, :time => time}
|
172
173
|
if @error_collector
|
174
|
+
# A record is not included in the logs because <@ERROR> handles it. This warn is for the notification
|
175
|
+
log.warn "send an error event to @ERROR:", error_info
|
176
|
+
@error_collector.emit(tag, time, record)
|
177
|
+
else
|
178
|
+
error_info[:record] = record
|
179
|
+
log.warn "dump an error event:", error_info
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def handle_emits_error(tag, es, error)
|
184
|
+
error_info = {:error_class => error.class, :error => error.to_s, :tag => tag}
|
185
|
+
if @error_collector
|
186
|
+
log.warn "send an error event stream to @ERROR:", error_info
|
173
187
|
@error_collector.emit_stream(tag, es)
|
174
188
|
else
|
175
189
|
now = Engine.now
|
176
190
|
if @suppress_emit_error_log_interval.zero? || now > @next_emit_error_log_time
|
177
|
-
log.warn "emit transaction failed
|
191
|
+
log.warn "emit transaction failed:", error_info
|
178
192
|
log.warn_backtrace
|
179
193
|
# log.debug "current next_emit_error_log_time: #{Time.at(@next_emit_error_log_time)}"
|
180
194
|
@next_emit_error_log_time = now + @suppress_emit_error_log_interval
|
181
195
|
# log.debug "next emit failure log suppressed"
|
182
196
|
# log.debug "next logged time is #{Time.at(@next_emit_error_log_time)}"
|
183
197
|
end
|
184
|
-
raise
|
198
|
+
raise error
|
185
199
|
end
|
186
200
|
end
|
187
201
|
|
@@ -198,10 +212,15 @@ module Fluent
|
|
198
212
|
suppress_interval(interval_time) unless interval_time.zero?
|
199
213
|
end
|
200
214
|
|
215
|
+
def emit_error_event(tag, time, record, error)
|
216
|
+
error_info = {:error_class => error.class, :error => error.to_s, :tag => tag, :time => time, :record => record}
|
217
|
+
log.warn "dump an error event in @ERROR:", error_info
|
218
|
+
end
|
219
|
+
|
201
220
|
def handle_emits_error(tag, es, e)
|
202
221
|
now = Engine.now
|
203
222
|
if @suppress_emit_error_log_interval.zero? || now > @next_emit_error_log_time
|
204
|
-
log.warn "emit transaction failed ", :error_class => e.class, :error => e
|
223
|
+
log.warn "emit transaction failed in @ERROR:", :error_class => e.class, :error => e
|
205
224
|
log.warn_backtrace
|
206
225
|
@next_emit_error_log_time = now + @suppress_emit_error_log_interval
|
207
226
|
end
|
data/lib/fluent/supervisor.rb
CHANGED
@@ -71,6 +71,11 @@ module Fluent
|
|
71
71
|
end
|
72
72
|
self
|
73
73
|
end
|
74
|
+
|
75
|
+
def level=(level)
|
76
|
+
@level = level
|
77
|
+
$log.level = level
|
78
|
+
end
|
74
79
|
end
|
75
80
|
|
76
81
|
def self.default_options
|
@@ -88,11 +93,13 @@ module Fluent
|
|
88
93
|
:suppress_repeated_stacktrace => true,
|
89
94
|
:without_source => false,
|
90
95
|
:use_v1_config => true,
|
96
|
+
:supervise => true,
|
91
97
|
}
|
92
98
|
end
|
93
99
|
|
94
100
|
def initialize(opt)
|
95
101
|
@daemonize = opt[:daemonize]
|
102
|
+
@supervise = opt[:supervise]
|
96
103
|
@config_path = opt[:config_path]
|
97
104
|
@inline_config = opt[:inline_config]
|
98
105
|
@use_v1_config = opt[:use_v1_config]
|
@@ -103,8 +110,6 @@ module Fluent
|
|
103
110
|
@chgroup = opt[:chgroup]
|
104
111
|
@chuser = opt[:chuser]
|
105
112
|
|
106
|
-
apply_system_config(opt)
|
107
|
-
|
108
113
|
@log_level = opt[:log_level]
|
109
114
|
@suppress_interval = opt[:suppress_interval]
|
110
115
|
@suppress_config_dump = opt[:suppress_config_dump]
|
@@ -118,13 +123,28 @@ module Fluent
|
|
118
123
|
|
119
124
|
def start
|
120
125
|
@log.init
|
126
|
+
read_config
|
127
|
+
apply_system_config
|
121
128
|
|
122
129
|
dry_run if @dry_run
|
123
130
|
start_daemonize if @daemonize
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
131
|
+
if @supervise
|
132
|
+
install_supervisor_signal_handlers
|
133
|
+
until @finished
|
134
|
+
supervise do
|
135
|
+
change_privilege
|
136
|
+
init_engine
|
137
|
+
install_main_process_signal_handlers
|
138
|
+
run_configure
|
139
|
+
finish_daemonize if @daemonize
|
140
|
+
run_engine
|
141
|
+
exit 0
|
142
|
+
end
|
143
|
+
$log.error "fluentd main process died unexpectedly. restarting." unless @finished
|
144
|
+
end
|
145
|
+
else
|
146
|
+
$log.info "starting fluentd-#{Fluent::VERSION} without supervision"
|
147
|
+
main_process do
|
128
148
|
change_privilege
|
129
149
|
init_engine
|
130
150
|
install_main_process_signal_handlers
|
@@ -133,7 +153,6 @@ module Fluent
|
|
133
153
|
run_engine
|
134
154
|
exit 0
|
135
155
|
end
|
136
|
-
$log.error "fluentd main process died unexpectedly. restarting." unless @finished
|
137
156
|
end
|
138
157
|
end
|
139
158
|
|
@@ -151,7 +170,6 @@ module Fluent
|
|
151
170
|
def dry_run
|
152
171
|
$log.info "starting fluentd-#{Fluent::VERSION} as dry run mode"
|
153
172
|
|
154
|
-
read_config
|
155
173
|
change_privilege
|
156
174
|
init_engine
|
157
175
|
install_main_process_signal_handlers
|
@@ -329,6 +347,7 @@ module Fluent
|
|
329
347
|
elsif @inline_config
|
330
348
|
@config_data << "\n" << @inline_config.gsub("\\n","\n")
|
331
349
|
end
|
350
|
+
@conf = Fluent::Config.parse(@config_data, @config_fname, @config_basedir, @use_v1_config)
|
332
351
|
end
|
333
352
|
|
334
353
|
class SystemConfig
|
@@ -347,37 +366,31 @@ module Fluent
|
|
347
366
|
configure(conf)
|
348
367
|
end
|
349
368
|
|
350
|
-
def
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
369
|
+
def apply(supervisor)
|
370
|
+
system = self
|
371
|
+
supervisor.instance_eval {
|
372
|
+
@log.level = @log_level = system.log_level unless system.log_level.nil?
|
373
|
+
@suppress_interval = system.emit_error_log_interval unless system.emit_error_log_interval.nil?
|
374
|
+
@suppress_config_dump = system.suppress_config_dump unless system.suppress_config_dump.nil?
|
375
|
+
@suppress_repeated_stacktrace = system.suppress_repeated_stacktrace unless system.suppress_repeated_stacktrace.nil?
|
376
|
+
@without_source = system.without_source unless system.without_source.nil?
|
377
|
+
}
|
358
378
|
end
|
359
379
|
end
|
360
380
|
|
361
381
|
# TODO: this method should be moved to SystemConfig class method
|
362
|
-
def apply_system_config
|
363
|
-
|
364
|
-
file = File.open(File::NULL)
|
365
|
-
$log = Fluent::Log.new(file, Log::LEVEL_INFO)
|
366
|
-
read_config
|
367
|
-
systems = Fluent::Config.parse(@config_data, @config_fname, @config_basedir, @use_v1_config).elements.select { |e|
|
382
|
+
def apply_system_config
|
383
|
+
systems = @conf.elements.select { |e|
|
368
384
|
e.name == 'system'
|
369
385
|
}
|
370
386
|
return if systems.empty?
|
371
387
|
raise ConfigError, "<system> is duplicated. <system> should be only one" if systems.size > 1
|
372
388
|
|
373
|
-
|
374
|
-
ensure
|
375
|
-
file.close
|
389
|
+
SystemConfig.new(systems.first).apply(self)
|
376
390
|
end
|
377
391
|
|
378
392
|
def run_configure
|
379
|
-
|
380
|
-
Fluent::Engine.run_configure(conf)
|
393
|
+
Fluent::Engine.run_configure(@conf)
|
381
394
|
end
|
382
395
|
|
383
396
|
def change_privilege
|
data/lib/fluent/test.rb
CHANGED
data/lib/fluent/test/base.rb
CHANGED
@@ -16,6 +16,20 @@
|
|
16
16
|
|
17
17
|
module Fluent
|
18
18
|
module Test
|
19
|
+
def self.setup
|
20
|
+
Fluent.__send__(:remove_const, :Engine)
|
21
|
+
engine = Fluent.const_set(:Engine, EngineClass.new).init
|
22
|
+
|
23
|
+
engine.define_singleton_method(:now=) {|n|
|
24
|
+
@now = n.to_i
|
25
|
+
}
|
26
|
+
engine.define_singleton_method(:now) {
|
27
|
+
@now || super()
|
28
|
+
}
|
29
|
+
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
|
19
33
|
class TestDriver
|
20
34
|
include ::Test::Unit::Assertions
|
21
35
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
module Fluent
|
18
|
+
module Test
|
19
|
+
class FilterTestDriver < TestDriver
|
20
|
+
def initialize(klass, &block)
|
21
|
+
super(klass, &block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def filter(tag, time, record)
|
25
|
+
@instance.filter(tag, time, record)
|
26
|
+
end
|
27
|
+
|
28
|
+
def filter_stream(tag, es)
|
29
|
+
@instance.filter_stream(tag, es)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -77,7 +77,13 @@ module Fluent
|
|
77
77
|
assert_equal(@expected_buffer, buffer)
|
78
78
|
end
|
79
79
|
|
80
|
-
|
80
|
+
key = ''
|
81
|
+
if @instance.respond_to?(:time_slicer)
|
82
|
+
# this block is only for test_out_file
|
83
|
+
time, record = @entries.first
|
84
|
+
key = @instance.time_slicer.call(time)
|
85
|
+
end
|
86
|
+
chunk = MemoryBufferChunk.new(key, buffer)
|
81
87
|
result = @instance.write(chunk)
|
82
88
|
}
|
83
89
|
result
|
data/lib/fluent/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
require_relative '../helper'
|
2
|
+
require_relative "assertions"
|
2
3
|
require "json"
|
3
|
-
require "config/assertions"
|
4
4
|
require "fluent/config/error"
|
5
5
|
require "fluent/config/basic_parser"
|
6
6
|
require "fluent/config/literal_parser"
|
@@ -229,6 +229,10 @@ module Fluent::Config
|
|
229
229
|
"ignores spacing around element argument" => [root(e("test", "a")), %[
|
230
230
|
<test a >
|
231
231
|
</test>
|
232
|
+
]],
|
233
|
+
"accepts spacing inside element argument (for multiple tags)" => [root(e("test", "a.** b.**")), %[
|
234
|
+
<test a.** b.** >
|
235
|
+
</test>
|
232
236
|
]])
|
233
237
|
def test_parse_element(data)
|
234
238
|
expected, target = data
|
data/test/config/test_dsl.rb
CHANGED
data/test/config/test_section.rb
CHANGED
@@ -1,49 +1,99 @@
|
|
1
|
-
|
1
|
+
require_relative '../helper'
|
2
2
|
require 'fluent/configurable'
|
3
3
|
require 'fluent/config/element'
|
4
4
|
require 'fluent/config/section'
|
5
5
|
require 'fluent/supervisor'
|
6
6
|
|
7
7
|
module Fluent::Config
|
8
|
+
class FakeLoggerInitializer
|
9
|
+
attr_accessor :level
|
10
|
+
def initalize
|
11
|
+
@level = nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class FakeSupervisor
|
16
|
+
def initialize
|
17
|
+
@log = FakeLoggerInitializer.new
|
18
|
+
@log_level = nil
|
19
|
+
@suppress_interval = nil
|
20
|
+
@suppress_config_dump = nil
|
21
|
+
@suppress_repeated_stacktrace = nil
|
22
|
+
@without_source = nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
8
26
|
class TestSystemConfig < ::Test::Unit::TestCase
|
27
|
+
|
9
28
|
def parse_text(text)
|
10
29
|
basepath = File.expand_path(File.dirname(__FILE__) + '/../../')
|
11
30
|
Fluent::Config.parse(text, '(test)', basepath, true).elements.find { |e| e.name == 'system' }
|
12
31
|
end
|
13
32
|
|
14
33
|
test 'should not override default configurations when no parameters' do
|
15
|
-
conf = parse_text(
|
16
|
-
<system>
|
17
|
-
</system>
|
18
|
-
EOS
|
34
|
+
conf = parse_text(<<-EOS)
|
35
|
+
<system>
|
36
|
+
</system>
|
37
|
+
EOS
|
38
|
+
s = FakeSupervisor.new
|
19
39
|
sc = Fluent::Supervisor::SystemConfig.new(conf)
|
40
|
+
sc.apply(s)
|
20
41
|
assert_nil(sc.log_level)
|
21
42
|
assert_nil(sc.suppress_repeated_stacktrace)
|
22
43
|
assert_nil(sc.emit_error_log_interval)
|
23
44
|
assert_nil(sc.suppress_config_dump)
|
24
45
|
assert_nil(sc.without_source)
|
25
|
-
|
46
|
+
assert_nil(s.instance_variable_get(:@log_level))
|
47
|
+
assert_nil(s.instance_variable_get(:@suppress_repeated_stacktrace))
|
48
|
+
assert_nil(s.instance_variable_get(:@emit_error_log_interval))
|
49
|
+
assert_nil(s.instance_variable_get(:@suppress_config_dump))
|
50
|
+
assert_nil(s.instance_variable_get(:@without_source))
|
26
51
|
end
|
27
52
|
|
28
|
-
{'log_level' => 'error',
|
53
|
+
{'log_level' => 'error',
|
54
|
+
'suppress_repeated_stacktrace' => true,
|
55
|
+
'emit_error_log_interval' => 60,
|
56
|
+
'suppress_config_dump' => true,
|
57
|
+
'without_source' => true,
|
58
|
+
}.each { |k, v|
|
29
59
|
test "accepts #{k} parameter" do
|
30
|
-
conf = parse_text(
|
31
|
-
<system>
|
32
|
-
|
33
|
-
</system>
|
34
|
-
EOS
|
60
|
+
conf = parse_text(<<-EOS)
|
61
|
+
<system>
|
62
|
+
#{k} #{v}
|
63
|
+
</system>
|
64
|
+
EOS
|
65
|
+
s = FakeSupervisor.new
|
35
66
|
sc = Fluent::Supervisor::SystemConfig.new(conf)
|
67
|
+
sc.apply(s)
|
36
68
|
assert_not_nil(sc.instance_variable_get("@#{k}"))
|
37
|
-
key = (k == 'emit_error_log_interval' ?
|
38
|
-
|
69
|
+
key = (k == 'emit_error_log_interval' ? 'suppress_interval' : k)
|
70
|
+
assert_not_nil(s.instance_variable_get("@#{key}"))
|
39
71
|
end
|
40
72
|
}
|
41
73
|
|
42
74
|
{'foo' => 'bar', 'hoge' => 'fuga'}.each { |k, v|
|
43
75
|
test "should not affect settable parameters with unknown #{k} parameter" do
|
76
|
+
s = FakeSupervisor.new
|
44
77
|
sc = Fluent::Supervisor::SystemConfig.new({k => v})
|
45
|
-
|
78
|
+
sc.apply(s)
|
79
|
+
assert_nil(s.instance_variable_get(:@log_level))
|
80
|
+
assert_nil(s.instance_variable_get(:@suppress_repeated_stacktrace))
|
81
|
+
assert_nil(s.instance_variable_get(:@emit_error_log_interval))
|
82
|
+
assert_nil(s.instance_variable_get(:@suppress_config_dump))
|
83
|
+
assert_nil(s.instance_variable_get(:@without_source))
|
46
84
|
end
|
47
85
|
}
|
86
|
+
|
87
|
+
test 'log_level' do
|
88
|
+
conf = parse_text(<<-EOS)
|
89
|
+
<system>
|
90
|
+
log_level warn
|
91
|
+
</system>
|
92
|
+
EOS
|
93
|
+
s = FakeSupervisor.new
|
94
|
+
sc = Fluent::Supervisor::SystemConfig.new(conf)
|
95
|
+
sc.apply(s)
|
96
|
+
assert_equal(Fluent::Log::LEVEL_WARN, s.instance_variable_get("@log").level)
|
97
|
+
end
|
48
98
|
end
|
49
99
|
end
|