fluentd 0.14.4-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 +7 -0
- data/.github/ISSUE_TEMPLATE.md +6 -0
- data/.gitignore +26 -0
- data/.travis.yml +45 -0
- data/AUTHORS +2 -0
- data/CONTRIBUTING.md +35 -0
- data/COPYING +14 -0
- data/ChangeLog +276 -0
- data/Gemfile +9 -0
- data/README.md +51 -0
- data/Rakefile +53 -0
- data/Vagrantfile +17 -0
- data/appveyor.yml +41 -0
- data/bin/fluent-debug +5 -0
- data/example/copy_roundrobin.conf +39 -0
- data/example/filter_stdout.conf +22 -0
- data/example/in_forward.conf +11 -0
- data/example/in_http.conf +14 -0
- data/example/in_out_forward.conf +17 -0
- data/example/in_syslog.conf +15 -0
- data/example/in_tail.conf +14 -0
- data/example/in_tcp.conf +13 -0
- data/example/in_udp.conf +13 -0
- data/example/multi_filters.conf +61 -0
- data/example/out_buffered_null.conf +32 -0
- data/example/out_copy.conf +20 -0
- data/example/out_file.conf +13 -0
- data/example/out_forward.conf +35 -0
- data/example/out_forward_buf_file.conf +23 -0
- data/example/v0_12_filter.conf +78 -0
- data/example/v1_literal_example.conf +36 -0
- data/fluent.conf +139 -0
- data/fluentd.gemspec +51 -0
- data/lib/fluent/agent.rb +194 -0
- data/lib/fluent/command/bundler_injection.rb +45 -0
- data/lib/fluent/command/cat.rb +319 -0
- data/lib/fluent/command/debug.rb +102 -0
- data/lib/fluent/command/fluentd.rb +273 -0
- data/lib/fluent/compat/call_super_mixin.rb +67 -0
- data/lib/fluent/compat/exec_util.rb +129 -0
- data/lib/fluent/compat/file_util.rb +54 -0
- data/lib/fluent/compat/filter.rb +68 -0
- data/lib/fluent/compat/formatter.rb +111 -0
- data/lib/fluent/compat/formatter_utils.rb +85 -0
- data/lib/fluent/compat/handle_tag_and_time_mixin.rb +62 -0
- data/lib/fluent/compat/handle_tag_name_mixin.rb +53 -0
- data/lib/fluent/compat/input.rb +49 -0
- data/lib/fluent/compat/output.rb +677 -0
- data/lib/fluent/compat/output_chain.rb +60 -0
- data/lib/fluent/compat/parser.rb +180 -0
- data/lib/fluent/compat/parser_utils.rb +40 -0
- data/lib/fluent/compat/propagate_default.rb +62 -0
- data/lib/fluent/compat/record_filter_mixin.rb +34 -0
- data/lib/fluent/compat/set_tag_key_mixin.rb +50 -0
- data/lib/fluent/compat/set_time_key_mixin.rb +69 -0
- data/lib/fluent/compat/socket_util.rb +165 -0
- data/lib/fluent/compat/string_util.rb +34 -0
- data/lib/fluent/compat/structured_format_mixin.rb +26 -0
- data/lib/fluent/compat/type_converter.rb +90 -0
- data/lib/fluent/config.rb +56 -0
- data/lib/fluent/config/basic_parser.rb +123 -0
- data/lib/fluent/config/configure_proxy.rb +366 -0
- data/lib/fluent/config/dsl.rb +149 -0
- data/lib/fluent/config/element.rb +218 -0
- data/lib/fluent/config/error.rb +26 -0
- data/lib/fluent/config/literal_parser.rb +251 -0
- data/lib/fluent/config/parser.rb +107 -0
- data/lib/fluent/config/section.rb +212 -0
- data/lib/fluent/config/types.rb +136 -0
- data/lib/fluent/config/v1_parser.rb +190 -0
- data/lib/fluent/configurable.rb +176 -0
- data/lib/fluent/daemon.rb +15 -0
- data/lib/fluent/engine.rb +220 -0
- data/lib/fluent/env.rb +27 -0
- data/lib/fluent/event.rb +287 -0
- data/lib/fluent/event_router.rb +259 -0
- data/lib/fluent/filter.rb +21 -0
- data/lib/fluent/formatter.rb +23 -0
- data/lib/fluent/input.rb +21 -0
- data/lib/fluent/label.rb +38 -0
- data/lib/fluent/load.rb +36 -0
- data/lib/fluent/log.rb +445 -0
- data/lib/fluent/match.rb +141 -0
- data/lib/fluent/mixin.rb +31 -0
- data/lib/fluent/msgpack_factory.rb +62 -0
- data/lib/fluent/output.rb +26 -0
- data/lib/fluent/output_chain.rb +23 -0
- data/lib/fluent/parser.rb +23 -0
- data/lib/fluent/plugin.rb +161 -0
- data/lib/fluent/plugin/bare_output.rb +63 -0
- data/lib/fluent/plugin/base.rb +130 -0
- data/lib/fluent/plugin/buf_file.rb +154 -0
- data/lib/fluent/plugin/buf_memory.rb +34 -0
- data/lib/fluent/plugin/buffer.rb +603 -0
- data/lib/fluent/plugin/buffer/chunk.rb +160 -0
- data/lib/fluent/plugin/buffer/file_chunk.rb +323 -0
- data/lib/fluent/plugin/buffer/memory_chunk.rb +90 -0
- data/lib/fluent/plugin/exec_util.rb +22 -0
- data/lib/fluent/plugin/file_util.rb +22 -0
- data/lib/fluent/plugin/file_wrapper.rb +120 -0
- data/lib/fluent/plugin/filter.rb +93 -0
- data/lib/fluent/plugin/filter_grep.rb +75 -0
- data/lib/fluent/plugin/filter_record_transformer.rb +342 -0
- data/lib/fluent/plugin/filter_stdout.rb +53 -0
- data/lib/fluent/plugin/formatter.rb +45 -0
- data/lib/fluent/plugin/formatter_csv.rb +47 -0
- data/lib/fluent/plugin/formatter_hash.rb +29 -0
- data/lib/fluent/plugin/formatter_json.rb +44 -0
- data/lib/fluent/plugin/formatter_ltsv.rb +41 -0
- data/lib/fluent/plugin/formatter_msgpack.rb +29 -0
- data/lib/fluent/plugin/formatter_out_file.rb +78 -0
- data/lib/fluent/plugin/formatter_single_value.rb +34 -0
- data/lib/fluent/plugin/formatter_stdout.rb +74 -0
- data/lib/fluent/plugin/in_debug_agent.rb +64 -0
- data/lib/fluent/plugin/in_dummy.rb +135 -0
- data/lib/fluent/plugin/in_exec.rb +149 -0
- data/lib/fluent/plugin/in_forward.rb +366 -0
- data/lib/fluent/plugin/in_gc_stat.rb +52 -0
- data/lib/fluent/plugin/in_http.rb +422 -0
- data/lib/fluent/plugin/in_monitor_agent.rb +401 -0
- data/lib/fluent/plugin/in_object_space.rb +90 -0
- data/lib/fluent/plugin/in_syslog.rb +204 -0
- data/lib/fluent/plugin/in_tail.rb +838 -0
- data/lib/fluent/plugin/in_tcp.rb +41 -0
- data/lib/fluent/plugin/in_udp.rb +37 -0
- data/lib/fluent/plugin/in_unix.rb +201 -0
- data/lib/fluent/plugin/input.rb +33 -0
- data/lib/fluent/plugin/multi_output.rb +95 -0
- data/lib/fluent/plugin/out_buffered_null.rb +59 -0
- data/lib/fluent/plugin/out_buffered_stdout.rb +70 -0
- data/lib/fluent/plugin/out_copy.rb +42 -0
- data/lib/fluent/plugin/out_exec.rb +114 -0
- data/lib/fluent/plugin/out_exec_filter.rb +393 -0
- data/lib/fluent/plugin/out_file.rb +167 -0
- data/lib/fluent/plugin/out_forward.rb +646 -0
- data/lib/fluent/plugin/out_null.rb +27 -0
- data/lib/fluent/plugin/out_relabel.rb +28 -0
- data/lib/fluent/plugin/out_roundrobin.rb +80 -0
- data/lib/fluent/plugin/out_stdout.rb +48 -0
- data/lib/fluent/plugin/out_stream.rb +130 -0
- data/lib/fluent/plugin/output.rb +1020 -0
- data/lib/fluent/plugin/owned_by_mixin.rb +42 -0
- data/lib/fluent/plugin/parser.rb +175 -0
- data/lib/fluent/plugin/parser_apache.rb +28 -0
- data/lib/fluent/plugin/parser_apache2.rb +84 -0
- data/lib/fluent/plugin/parser_apache_error.rb +26 -0
- data/lib/fluent/plugin/parser_csv.rb +33 -0
- data/lib/fluent/plugin/parser_json.rb +79 -0
- data/lib/fluent/plugin/parser_ltsv.rb +50 -0
- data/lib/fluent/plugin/parser_multiline.rb +104 -0
- data/lib/fluent/plugin/parser_nginx.rb +28 -0
- data/lib/fluent/plugin/parser_none.rb +36 -0
- data/lib/fluent/plugin/parser_regexp.rb +73 -0
- data/lib/fluent/plugin/parser_syslog.rb +82 -0
- data/lib/fluent/plugin/parser_tsv.rb +37 -0
- data/lib/fluent/plugin/socket_util.rb +22 -0
- data/lib/fluent/plugin/storage.rb +84 -0
- data/lib/fluent/plugin/storage_local.rb +132 -0
- data/lib/fluent/plugin/string_util.rb +22 -0
- data/lib/fluent/plugin_helper.rb +42 -0
- data/lib/fluent/plugin_helper/child_process.rb +298 -0
- data/lib/fluent/plugin_helper/compat_parameters.rb +224 -0
- data/lib/fluent/plugin_helper/event_emitter.rb +80 -0
- data/lib/fluent/plugin_helper/event_loop.rb +118 -0
- data/lib/fluent/plugin_helper/formatter.rb +149 -0
- data/lib/fluent/plugin_helper/inject.rb +125 -0
- data/lib/fluent/plugin_helper/parser.rb +147 -0
- data/lib/fluent/plugin_helper/retry_state.rb +177 -0
- data/lib/fluent/plugin_helper/storage.rb +331 -0
- data/lib/fluent/plugin_helper/thread.rb +147 -0
- data/lib/fluent/plugin_helper/timer.rb +90 -0
- data/lib/fluent/plugin_id.rb +63 -0
- data/lib/fluent/process.rb +504 -0
- data/lib/fluent/registry.rb +99 -0
- data/lib/fluent/root_agent.rb +314 -0
- data/lib/fluent/rpc.rb +94 -0
- data/lib/fluent/supervisor.rb +680 -0
- data/lib/fluent/system_config.rb +122 -0
- data/lib/fluent/test.rb +56 -0
- data/lib/fluent/test/base.rb +85 -0
- data/lib/fluent/test/driver/base.rb +179 -0
- data/lib/fluent/test/driver/base_owned.rb +70 -0
- data/lib/fluent/test/driver/base_owner.rb +125 -0
- data/lib/fluent/test/driver/event_feeder.rb +98 -0
- data/lib/fluent/test/driver/filter.rb +57 -0
- data/lib/fluent/test/driver/formatter.rb +30 -0
- data/lib/fluent/test/driver/input.rb +31 -0
- data/lib/fluent/test/driver/multi_output.rb +52 -0
- data/lib/fluent/test/driver/output.rb +76 -0
- data/lib/fluent/test/driver/parser.rb +30 -0
- data/lib/fluent/test/driver/test_event_router.rb +45 -0
- data/lib/fluent/test/filter_test.rb +77 -0
- data/lib/fluent/test/formatter_test.rb +65 -0
- data/lib/fluent/test/helpers.rb +79 -0
- data/lib/fluent/test/input_test.rb +172 -0
- data/lib/fluent/test/log.rb +73 -0
- data/lib/fluent/test/output_test.rb +156 -0
- data/lib/fluent/test/parser_test.rb +70 -0
- data/lib/fluent/time.rb +175 -0
- data/lib/fluent/timezone.rb +133 -0
- data/lib/fluent/unique_id.rb +39 -0
- data/lib/fluent/version.rb +21 -0
- data/lib/fluent/winsvc.rb +71 -0
- data/test/compat/test_calls_super.rb +166 -0
- data/test/compat/test_parser.rb +82 -0
- data/test/config/assertions.rb +42 -0
- data/test/config/test_config_parser.rb +507 -0
- data/test/config/test_configurable.rb +1194 -0
- data/test/config/test_configure_proxy.rb +386 -0
- data/test/config/test_dsl.rb +415 -0
- data/test/config/test_element.rb +403 -0
- data/test/config/test_literal_parser.rb +297 -0
- data/test/config/test_section.rb +184 -0
- data/test/config/test_system_config.rb +120 -0
- data/test/config/test_types.rb +171 -0
- data/test/helper.rb +119 -0
- data/test/plugin/data/2010/01/20100102-030405.log +0 -0
- data/test/plugin/data/2010/01/20100102-030406.log +0 -0
- data/test/plugin/data/2010/01/20100102.log +0 -0
- data/test/plugin/data/log/bar +0 -0
- data/test/plugin/data/log/foo/bar.log +0 -0
- data/test/plugin/data/log/test.log +0 -0
- data/test/plugin/test_bare_output.rb +118 -0
- data/test/plugin/test_base.rb +75 -0
- data/test/plugin/test_buf_file.rb +571 -0
- data/test/plugin/test_buf_memory.rb +42 -0
- data/test/plugin/test_buffer.rb +1200 -0
- data/test/plugin/test_buffer_chunk.rb +168 -0
- data/test/plugin/test_buffer_file_chunk.rb +771 -0
- data/test/plugin/test_buffer_memory_chunk.rb +265 -0
- data/test/plugin/test_file_util.rb +96 -0
- data/test/plugin/test_filter.rb +353 -0
- data/test/plugin/test_filter_grep.rb +119 -0
- data/test/plugin/test_filter_record_transformer.rb +600 -0
- data/test/plugin/test_filter_stdout.rb +211 -0
- data/test/plugin/test_formatter_csv.rb +94 -0
- data/test/plugin/test_formatter_json.rb +30 -0
- data/test/plugin/test_formatter_ltsv.rb +52 -0
- data/test/plugin/test_formatter_msgpack.rb +28 -0
- data/test/plugin/test_formatter_out_file.rb +95 -0
- data/test/plugin/test_formatter_single_value.rb +38 -0
- data/test/plugin/test_in_debug_agent.rb +28 -0
- data/test/plugin/test_in_dummy.rb +188 -0
- data/test/plugin/test_in_exec.rb +133 -0
- data/test/plugin/test_in_forward.rb +635 -0
- data/test/plugin/test_in_gc_stat.rb +39 -0
- data/test/plugin/test_in_http.rb +442 -0
- data/test/plugin/test_in_monitor_agent.rb +329 -0
- data/test/plugin/test_in_object_space.rb +64 -0
- data/test/plugin/test_in_syslog.rb +205 -0
- data/test/plugin/test_in_tail.rb +1001 -0
- data/test/plugin/test_in_tcp.rb +102 -0
- data/test/plugin/test_in_udp.rb +121 -0
- data/test/plugin/test_in_unix.rb +126 -0
- data/test/plugin/test_input.rb +122 -0
- data/test/plugin/test_multi_output.rb +180 -0
- data/test/plugin/test_out_buffered_null.rb +79 -0
- data/test/plugin/test_out_buffered_stdout.rb +122 -0
- data/test/plugin/test_out_copy.rb +160 -0
- data/test/plugin/test_out_exec.rb +155 -0
- data/test/plugin/test_out_exec_filter.rb +262 -0
- data/test/plugin/test_out_file.rb +383 -0
- data/test/plugin/test_out_forward.rb +590 -0
- data/test/plugin/test_out_null.rb +29 -0
- data/test/plugin/test_out_relabel.rb +28 -0
- data/test/plugin/test_out_roundrobin.rb +146 -0
- data/test/plugin/test_out_stdout.rb +92 -0
- data/test/plugin/test_out_stream.rb +93 -0
- data/test/plugin/test_output.rb +568 -0
- data/test/plugin/test_output_as_buffered.rb +1604 -0
- data/test/plugin/test_output_as_buffered_overflow.rb +250 -0
- data/test/plugin/test_output_as_buffered_retries.rb +839 -0
- data/test/plugin/test_output_as_buffered_secondary.rb +817 -0
- data/test/plugin/test_output_as_standard.rb +374 -0
- data/test/plugin/test_owned_by.rb +35 -0
- data/test/plugin/test_parser_apache.rb +42 -0
- data/test/plugin/test_parser_apache2.rb +38 -0
- data/test/plugin/test_parser_apache_error.rb +45 -0
- data/test/plugin/test_parser_base.rb +32 -0
- data/test/plugin/test_parser_csv.rb +104 -0
- data/test/plugin/test_parser_json.rb +107 -0
- data/test/plugin/test_parser_labeled_tsv.rb +129 -0
- data/test/plugin/test_parser_multiline.rb +100 -0
- data/test/plugin/test_parser_nginx.rb +48 -0
- data/test/plugin/test_parser_none.rb +53 -0
- data/test/plugin/test_parser_regexp.rb +277 -0
- data/test/plugin/test_parser_syslog.rb +66 -0
- data/test/plugin/test_parser_time.rb +46 -0
- data/test/plugin/test_parser_tsv.rb +121 -0
- data/test/plugin/test_storage.rb +167 -0
- data/test/plugin/test_storage_local.rb +8 -0
- data/test/plugin/test_string_util.rb +26 -0
- data/test/plugin_helper/test_child_process.rb +608 -0
- data/test/plugin_helper/test_compat_parameters.rb +242 -0
- data/test/plugin_helper/test_event_emitter.rb +51 -0
- data/test/plugin_helper/test_event_loop.rb +52 -0
- data/test/plugin_helper/test_formatter.rb +252 -0
- data/test/plugin_helper/test_inject.rb +487 -0
- data/test/plugin_helper/test_parser.rb +263 -0
- data/test/plugin_helper/test_retry_state.rb +399 -0
- data/test/plugin_helper/test_storage.rb +521 -0
- data/test/plugin_helper/test_thread.rb +164 -0
- data/test/plugin_helper/test_timer.rb +131 -0
- data/test/scripts/exec_script.rb +32 -0
- data/test/scripts/fluent/plugin/formatter_known.rb +8 -0
- data/test/scripts/fluent/plugin/out_test.rb +81 -0
- data/test/scripts/fluent/plugin/out_test2.rb +80 -0
- data/test/scripts/fluent/plugin/parser_known.rb +4 -0
- data/test/test_config.rb +179 -0
- data/test/test_configdsl.rb +148 -0
- data/test/test_event.rb +329 -0
- data/test/test_event_router.rb +331 -0
- data/test/test_event_time.rb +184 -0
- data/test/test_filter.rb +121 -0
- data/test/test_formatter.rb +319 -0
- data/test/test_input.rb +31 -0
- data/test/test_log.rb +572 -0
- data/test/test_match.rb +137 -0
- data/test/test_mixin.rb +351 -0
- data/test/test_output.rb +214 -0
- data/test/test_plugin_classes.rb +136 -0
- data/test/test_plugin_helper.rb +81 -0
- data/test/test_process.rb +48 -0
- data/test/test_root_agent.rb +278 -0
- data/test/test_supervisor.rb +339 -0
- data/test/test_time_formatter.rb +186 -0
- data/test/test_unique_id.rb +47 -0
- metadata +823 -0
@@ -0,0 +1,218 @@
|
|
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
|
+
require 'fluent/config/error'
|
18
|
+
require 'fluent/config/literal_parser'
|
19
|
+
|
20
|
+
module Fluent
|
21
|
+
module Config
|
22
|
+
class Element < Hash
|
23
|
+
def initialize(name, arg, attrs, elements, unused = nil)
|
24
|
+
@name = name
|
25
|
+
@arg = arg
|
26
|
+
@elements = elements
|
27
|
+
super()
|
28
|
+
attrs.each { |k, v|
|
29
|
+
self[k] = v
|
30
|
+
}
|
31
|
+
@unused = unused || attrs.keys
|
32
|
+
@v1_config = false
|
33
|
+
@corresponding_proxies = [] # some plugins use flat parameters, e.g. in_http doesn't provide <format> section for parser.
|
34
|
+
@unused_in = false # if this element is not used in plugins, correspoing plugin name and parent element name is set, e.g. [source, plugin class].
|
35
|
+
|
36
|
+
# it's global logger, not plugin logger: deprecated message should be global warning, not plugin level.
|
37
|
+
@logger = defined?($log) ? $log : nil
|
38
|
+
end
|
39
|
+
|
40
|
+
attr_accessor :name, :arg, :unused, :v1_config, :corresponding_proxies, :unused_in
|
41
|
+
attr_writer :elements
|
42
|
+
|
43
|
+
RESERVED_PARAMETERS_COMPAT = {
|
44
|
+
'@type' => 'type',
|
45
|
+
'@id' => 'id',
|
46
|
+
'@log_level' => 'log_level',
|
47
|
+
'@label' => nil,
|
48
|
+
}
|
49
|
+
RESERVED_PARAMETERS = RESERVED_PARAMETERS_COMPAT.keys
|
50
|
+
|
51
|
+
def elements(*names, name: nil, arg: nil)
|
52
|
+
raise ArgumentError, "name and names are exclusive" if name && !names.empty?
|
53
|
+
raise ArgumentError, "arg is available only with name" if arg && !name
|
54
|
+
|
55
|
+
if name
|
56
|
+
@elements.select{|e| e.name == name && (!arg || e.arg == arg) }
|
57
|
+
elsif !names.empty?
|
58
|
+
@elements.select{|e| names.include?(e.name) }
|
59
|
+
else
|
60
|
+
@elements
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def add_element(name, arg = '')
|
65
|
+
e = Element.new(name, arg, {}, [])
|
66
|
+
e.v1_config = @v1_config
|
67
|
+
@elements << e
|
68
|
+
e
|
69
|
+
end
|
70
|
+
|
71
|
+
def inspect
|
72
|
+
attrs = super
|
73
|
+
"name:#{@name}, arg:#{@arg}, " + attrs + ", " + @elements.inspect
|
74
|
+
end
|
75
|
+
|
76
|
+
# This method assumes _o_ is an Element object. Should return false for nil or other object
|
77
|
+
def ==(o)
|
78
|
+
self.name == o.name && self.arg == o.arg &&
|
79
|
+
self.keys.size == o.keys.size &&
|
80
|
+
self.keys.reduce(true){|r, k| r && self[k] == o[k] } &&
|
81
|
+
self.elements.size == o.elements.size &&
|
82
|
+
[self.elements, o.elements].transpose.reduce(true){|r, e| r && e[0] == e[1] }
|
83
|
+
end
|
84
|
+
|
85
|
+
def +(o)
|
86
|
+
e = Element.new(@name.dup, @arg.dup, o.merge(self), @elements + o.elements, (@unused + o.unused).uniq)
|
87
|
+
e.v1_config = @v1_config
|
88
|
+
e
|
89
|
+
end
|
90
|
+
|
91
|
+
# no code in fluentd uses this method
|
92
|
+
def each_element(*names, &block)
|
93
|
+
if names.empty?
|
94
|
+
@elements.each(&block)
|
95
|
+
else
|
96
|
+
@elements.each { |e|
|
97
|
+
if names.include?(e.name)
|
98
|
+
block.yield(e)
|
99
|
+
end
|
100
|
+
}
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def has_key?(key)
|
105
|
+
@unused_in = false # some sections, e.g. <store> in copy, is not defined by config_section so clear unused flag for better warning message in chgeck_not_fetched.
|
106
|
+
@unused.delete(key)
|
107
|
+
super
|
108
|
+
end
|
109
|
+
|
110
|
+
def [](key)
|
111
|
+
@unused_in = false # ditto
|
112
|
+
@unused.delete(key)
|
113
|
+
|
114
|
+
if RESERVED_PARAMETERS.include?(key) && !has_key?(key) && has_key?(RESERVED_PARAMETERS_COMPAT[key])
|
115
|
+
@logger.warn "'#{RESERVED_PARAMETERS_COMPAT[key]}' is deprecated parameter name. use '#{key}' instead." if @logger
|
116
|
+
return self[RESERVED_PARAMETERS_COMPAT[key]]
|
117
|
+
end
|
118
|
+
|
119
|
+
super
|
120
|
+
end
|
121
|
+
|
122
|
+
def check_not_fetched(&block)
|
123
|
+
each_key { |key|
|
124
|
+
if @unused.include?(key)
|
125
|
+
block.call(key, self)
|
126
|
+
end
|
127
|
+
}
|
128
|
+
@elements.each { |e|
|
129
|
+
e.check_not_fetched(&block)
|
130
|
+
}
|
131
|
+
end
|
132
|
+
|
133
|
+
def to_s(nest = 0)
|
134
|
+
indent = " " * nest
|
135
|
+
nindent = " " * (nest + 1)
|
136
|
+
out = ""
|
137
|
+
if @arg.empty?
|
138
|
+
out << "#{indent}<#{@name}>\n"
|
139
|
+
else
|
140
|
+
out << "#{indent}<#{@name} #{@arg}>\n"
|
141
|
+
end
|
142
|
+
each_pair { |k, v|
|
143
|
+
out << dump_value(k, v, nindent)
|
144
|
+
}
|
145
|
+
@elements.each { |e|
|
146
|
+
out << e.to_s(nest + 1)
|
147
|
+
}
|
148
|
+
out << "#{indent}</#{@name}>\n"
|
149
|
+
out
|
150
|
+
end
|
151
|
+
|
152
|
+
def to_masked_element
|
153
|
+
new_elems = @elements.map { |e| e.to_masked_element }
|
154
|
+
new_elem = Element.new(@name, @arg, {}, new_elems, @unused)
|
155
|
+
new_elem.v1_config = @v1_config
|
156
|
+
new_elem.corresponding_proxies = @corresponding_proxies
|
157
|
+
each_pair { |k, v|
|
158
|
+
new_elem[k] = secret_param?(k) ? 'xxxxxx' : v
|
159
|
+
}
|
160
|
+
new_elem
|
161
|
+
end
|
162
|
+
|
163
|
+
def secret_param?(key)
|
164
|
+
return false if @corresponding_proxies.empty?
|
165
|
+
|
166
|
+
param_key = key.to_sym
|
167
|
+
@corresponding_proxies.each { |proxy|
|
168
|
+
_block, opts = proxy.params[param_key]
|
169
|
+
if opts && opts.has_key?(:secret)
|
170
|
+
return opts[:secret]
|
171
|
+
end
|
172
|
+
}
|
173
|
+
|
174
|
+
false
|
175
|
+
end
|
176
|
+
|
177
|
+
def param_type(key)
|
178
|
+
return nil if @corresponding_proxies.empty?
|
179
|
+
|
180
|
+
param_key = key.to_sym
|
181
|
+
proxy = @corresponding_proxies.detect do |_proxy|
|
182
|
+
_proxy.params.has_key?(param_key)
|
183
|
+
end
|
184
|
+
return nil unless proxy
|
185
|
+
_block, opts = proxy.params[param_key]
|
186
|
+
opts[:type]
|
187
|
+
end
|
188
|
+
|
189
|
+
def dump_value(k, v, nindent)
|
190
|
+
if secret_param?(k)
|
191
|
+
"#{nindent}#{k} xxxxxx\n"
|
192
|
+
else
|
193
|
+
if @v1_config
|
194
|
+
case param_type(k)
|
195
|
+
when :string
|
196
|
+
"#{nindent}#{k} \"#{self.class.unescape_parameter(v)}\"\n"
|
197
|
+
when :enum, :integer, :float, :size, :bool, :time
|
198
|
+
"#{nindent}#{k} #{v}\n"
|
199
|
+
when :hash, :array
|
200
|
+
"#{nindent}#{k} #{v}\n"
|
201
|
+
else
|
202
|
+
# Unknown type
|
203
|
+
"#{nindent}#{k} #{v}\n"
|
204
|
+
end
|
205
|
+
else
|
206
|
+
"#{nindent}#{k} #{v}\n"
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def self.unescape_parameter(v)
|
212
|
+
result = ''
|
213
|
+
v.each_char { |c| result << LiteralParser.unescape_char(c) }
|
214
|
+
result
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
@@ -0,0 +1,26 @@
|
|
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
|
+
class ConfigError < StandardError
|
19
|
+
end
|
20
|
+
|
21
|
+
class ConfigParseError < ConfigError
|
22
|
+
end
|
23
|
+
|
24
|
+
class ObsoletedParameterError < ConfigError
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,251 @@
|
|
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
|
+
require 'stringio'
|
18
|
+
|
19
|
+
require 'json'
|
20
|
+
require 'yajl'
|
21
|
+
require 'irb/ruby-lex' # RubyLex
|
22
|
+
|
23
|
+
require 'fluent/config/basic_parser'
|
24
|
+
|
25
|
+
module Fluent
|
26
|
+
module Config
|
27
|
+
class LiteralParser < BasicParser
|
28
|
+
def self.unescape_char(c)
|
29
|
+
case c
|
30
|
+
when '"'
|
31
|
+
'\"'
|
32
|
+
when "'"
|
33
|
+
"\\'"
|
34
|
+
when '\\'
|
35
|
+
'\\\\'
|
36
|
+
when "\r"
|
37
|
+
'\r'
|
38
|
+
when "\n"
|
39
|
+
'\n'
|
40
|
+
when "\t"
|
41
|
+
'\t'
|
42
|
+
when "\f"
|
43
|
+
'\f'
|
44
|
+
when "\b"
|
45
|
+
'\b'
|
46
|
+
else
|
47
|
+
c
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def initialize(strscan, eval_context)
|
52
|
+
super(strscan)
|
53
|
+
@eval_context = eval_context
|
54
|
+
end
|
55
|
+
|
56
|
+
def parse_literal(string_boundary_charset = LINE_END)
|
57
|
+
spacing_without_comment
|
58
|
+
|
59
|
+
value = if skip(/\[/)
|
60
|
+
scan_json(true)
|
61
|
+
elsif skip(/\{/)
|
62
|
+
scan_json(false)
|
63
|
+
else
|
64
|
+
scan_string(string_boundary_charset)
|
65
|
+
end
|
66
|
+
value
|
67
|
+
end
|
68
|
+
|
69
|
+
def scan_string(string_boundary_charset = LINE_END)
|
70
|
+
if skip(/\"/)
|
71
|
+
return scan_double_quoted_string
|
72
|
+
elsif skip(/\'/)
|
73
|
+
return scan_single_quoted_string
|
74
|
+
else
|
75
|
+
return scan_nonquoted_string(string_boundary_charset)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def scan_double_quoted_string
|
80
|
+
string = []
|
81
|
+
while true
|
82
|
+
if skip(/\"/)
|
83
|
+
return string.join
|
84
|
+
elsif check(/[^"]#{LINE_END_WITHOUT_SPACING_AND_COMMENT}/)
|
85
|
+
if s = check(/[^\\]#{LINE_END_WITHOUT_SPACING_AND_COMMENT}/)
|
86
|
+
string << s
|
87
|
+
end
|
88
|
+
skip(/[^"]#{LINE_END_WITHOUT_SPACING_AND_COMMENT}/)
|
89
|
+
elsif s = scan(/\\./)
|
90
|
+
string << eval_escape_char(s[1,1])
|
91
|
+
elsif skip(/\#\{/)
|
92
|
+
string << eval_embedded_code(scan_embedded_code)
|
93
|
+
skip(/\}/)
|
94
|
+
elsif s = scan(/./)
|
95
|
+
string << s
|
96
|
+
else
|
97
|
+
parse_error! "unexpected end of file in a double quoted string"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def scan_single_quoted_string
|
103
|
+
string = []
|
104
|
+
while true
|
105
|
+
if skip(/\'/)
|
106
|
+
return string.join
|
107
|
+
elsif s = scan(/\\'/)
|
108
|
+
string << "'"
|
109
|
+
elsif s = scan(/\\\\/)
|
110
|
+
string << "\\"
|
111
|
+
elsif s = scan(/./)
|
112
|
+
string << s
|
113
|
+
else
|
114
|
+
parse_error! "unexpected end of file in a signle quoted string"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def scan_nonquoted_string(boundary_charset = LINE_END)
|
120
|
+
charset = /(?!#{boundary_charset})./
|
121
|
+
|
122
|
+
string = []
|
123
|
+
while true
|
124
|
+
if s = scan(/\#/)
|
125
|
+
string << '#'
|
126
|
+
elsif s = scan(charset)
|
127
|
+
string << s
|
128
|
+
else
|
129
|
+
break
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
if string.empty?
|
134
|
+
return nil
|
135
|
+
end
|
136
|
+
|
137
|
+
string.join
|
138
|
+
end
|
139
|
+
|
140
|
+
def scan_embedded_code
|
141
|
+
rlex = RubyLex.new
|
142
|
+
src = '"#{'+@ss.rest+"\n=end\n}"
|
143
|
+
|
144
|
+
input = StringIO.new(src)
|
145
|
+
input.define_singleton_method(:encoding) { external_encoding }
|
146
|
+
rlex.set_input(input)
|
147
|
+
|
148
|
+
tk = rlex.token
|
149
|
+
code = src[3,tk.seek-3]
|
150
|
+
|
151
|
+
if @ss.rest.length < code.length
|
152
|
+
@ss.pos += @ss.rest.length
|
153
|
+
parse_error! "expected end of embedded code but $end"
|
154
|
+
end
|
155
|
+
|
156
|
+
@ss.pos += code.length
|
157
|
+
|
158
|
+
'"#{' + code + '}"'
|
159
|
+
end
|
160
|
+
|
161
|
+
def eval_embedded_code(code)
|
162
|
+
if @eval_context.nil?
|
163
|
+
parse_error! "embedded code is not allowed in this file"
|
164
|
+
end
|
165
|
+
@eval_context.instance_eval(code)
|
166
|
+
end
|
167
|
+
|
168
|
+
def eval_escape_char(c)
|
169
|
+
case c
|
170
|
+
when '"'
|
171
|
+
'"'
|
172
|
+
when "'"
|
173
|
+
"'"
|
174
|
+
when "r"
|
175
|
+
"\r"
|
176
|
+
when "n"
|
177
|
+
"\n"
|
178
|
+
when "t"
|
179
|
+
"\t"
|
180
|
+
when "f"
|
181
|
+
"\f"
|
182
|
+
when "b"
|
183
|
+
"\b"
|
184
|
+
when /[a-zA-Z0-9]/
|
185
|
+
parse_error! "unexpected back-slash escape character '#{c}'"
|
186
|
+
else # symbols
|
187
|
+
c
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def scan_json(is_array)
|
192
|
+
result = nil
|
193
|
+
# Yajl does not raise ParseError for imcomplete json string, like '[1', '{"h"', '{"h":' or '{"h1":1'
|
194
|
+
# This is the reason to use JSON module.
|
195
|
+
|
196
|
+
buffer = (is_array ? "[" : "{")
|
197
|
+
line_buffer = ""
|
198
|
+
|
199
|
+
until result
|
200
|
+
char = getch
|
201
|
+
|
202
|
+
break if char.nil?
|
203
|
+
|
204
|
+
if char == "#"
|
205
|
+
# If this is out of json string literals, this object can be parsed correctly
|
206
|
+
# '{"foo":"bar", #' -> '{"foo":"bar"}' (to check)
|
207
|
+
parsed = nil
|
208
|
+
begin
|
209
|
+
parsed = JSON.parse(buffer + line_buffer.rstrip.sub(/,$/, '') + (is_array ? "]" : "}"))
|
210
|
+
rescue JSON::ParserError => e
|
211
|
+
# This '#' is in json string literals
|
212
|
+
end
|
213
|
+
|
214
|
+
if parsed
|
215
|
+
# ignore chars as comment before newline
|
216
|
+
while (char = getch) != "\n"
|
217
|
+
# ignore comment char
|
218
|
+
end
|
219
|
+
buffer << line_buffer + "\n"
|
220
|
+
line_buffer = ""
|
221
|
+
else
|
222
|
+
# '#' is a char in json string
|
223
|
+
line_buffer << char
|
224
|
+
end
|
225
|
+
|
226
|
+
next # This char '#' MUST NOT terminate json object.
|
227
|
+
end
|
228
|
+
|
229
|
+
if char == "\n"
|
230
|
+
buffer << line_buffer + "\n"
|
231
|
+
line_buffer = ""
|
232
|
+
next
|
233
|
+
end
|
234
|
+
|
235
|
+
line_buffer << char
|
236
|
+
begin
|
237
|
+
result = JSON.parse(buffer + line_buffer)
|
238
|
+
rescue JSON::ParserError => e
|
239
|
+
# Incomplete json string yet
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
unless result
|
244
|
+
parse_error! "got incomplete JSON #{is_array ? 'array' : 'hash'} configuration"
|
245
|
+
end
|
246
|
+
|
247
|
+
JSON.dump(result)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|