fluentd 0.12.40 → 0.14.0
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.md +6 -0
- data/.gitignore +2 -0
- data/.travis.yml +33 -21
- data/CONTRIBUTING.md +1 -0
- data/ChangeLog +810 -237
- data/README.md +0 -25
- data/Rakefile +2 -1
- data/Vagrantfile +17 -0
- data/appveyor.yml +35 -0
- data/example/filter_stdout.conf +5 -5
- data/example/in_forward.conf +2 -2
- data/example/in_http.conf +2 -2
- data/example/in_out_forward.conf +17 -0
- data/example/in_syslog.conf +2 -2
- data/example/in_tail.conf +2 -2
- data/example/in_tcp.conf +2 -2
- data/example/in_udp.conf +2 -2
- data/example/out_copy.conf +4 -4
- data/example/out_file.conf +2 -2
- data/example/out_forward.conf +2 -2
- data/example/out_forward_buf_file.conf +23 -0
- data/example/v0_12_filter.conf +8 -8
- data/fluent.conf +29 -0
- data/fluentd.gemspec +18 -11
- data/lib/fluent/agent.rb +60 -58
- data/lib/fluent/command/cat.rb +1 -1
- data/lib/fluent/command/debug.rb +7 -5
- data/lib/fluent/command/fluentd.rb +97 -2
- data/lib/fluent/compat/call_super_mixin.rb +67 -0
- data/lib/fluent/compat/filter.rb +50 -0
- data/lib/fluent/compat/formatter.rb +109 -0
- data/lib/fluent/compat/input.rb +50 -0
- data/lib/fluent/compat/output.rb +617 -0
- data/lib/fluent/compat/output_chain.rb +60 -0
- data/lib/fluent/compat/parser.rb +163 -0
- data/lib/fluent/compat/propagate_default.rb +62 -0
- data/lib/fluent/config.rb +23 -20
- data/lib/fluent/config/configure_proxy.rb +119 -70
- data/lib/fluent/config/dsl.rb +5 -18
- data/lib/fluent/config/element.rb +72 -8
- data/lib/fluent/config/error.rb +0 -3
- data/lib/fluent/config/literal_parser.rb +0 -2
- data/lib/fluent/config/parser.rb +4 -4
- data/lib/fluent/config/section.rb +39 -28
- data/lib/fluent/config/types.rb +2 -13
- data/lib/fluent/config/v1_parser.rb +1 -3
- data/lib/fluent/configurable.rb +48 -16
- data/lib/fluent/daemon.rb +15 -0
- data/lib/fluent/engine.rb +26 -52
- data/lib/fluent/env.rb +6 -4
- data/lib/fluent/event.rb +58 -11
- data/lib/fluent/event_router.rb +5 -5
- data/lib/fluent/filter.rb +2 -50
- data/lib/fluent/formatter.rb +4 -293
- data/lib/fluent/input.rb +2 -32
- data/lib/fluent/label.rb +2 -2
- data/lib/fluent/load.rb +3 -2
- data/lib/fluent/log.rb +107 -38
- data/lib/fluent/match.rb +0 -36
- data/lib/fluent/mixin.rb +117 -7
- data/lib/fluent/msgpack_factory.rb +62 -0
- data/lib/fluent/output.rb +7 -612
- data/lib/fluent/output_chain.rb +23 -0
- data/lib/fluent/parser.rb +4 -800
- data/lib/fluent/plugin.rb +100 -121
- data/lib/fluent/plugin/bare_output.rb +63 -0
- data/lib/fluent/plugin/base.rb +121 -0
- data/lib/fluent/plugin/buf_file.rb +101 -182
- data/lib/fluent/plugin/buf_memory.rb +9 -92
- data/lib/fluent/plugin/buffer.rb +473 -0
- data/lib/fluent/plugin/buffer/chunk.rb +135 -0
- data/lib/fluent/plugin/buffer/file_chunk.rb +339 -0
- data/lib/fluent/plugin/buffer/memory_chunk.rb +100 -0
- data/lib/fluent/plugin/exec_util.rb +80 -75
- data/lib/fluent/plugin/file_util.rb +33 -28
- data/lib/fluent/plugin/file_wrapper.rb +120 -0
- data/lib/fluent/plugin/filter.rb +51 -0
- data/lib/fluent/plugin/filter_grep.rb +13 -40
- data/lib/fluent/plugin/filter_record_transformer.rb +22 -18
- data/lib/fluent/plugin/formatter.rb +93 -0
- data/lib/fluent/plugin/formatter_csv.rb +48 -0
- data/lib/fluent/plugin/formatter_hash.rb +32 -0
- data/lib/fluent/plugin/formatter_json.rb +47 -0
- data/lib/fluent/plugin/formatter_ltsv.rb +42 -0
- data/lib/fluent/plugin/formatter_msgpack.rb +32 -0
- data/lib/fluent/plugin/formatter_out_file.rb +45 -0
- data/lib/fluent/plugin/formatter_single_value.rb +34 -0
- data/lib/fluent/plugin/formatter_stdout.rb +39 -0
- data/lib/fluent/plugin/in_debug_agent.rb +4 -0
- data/lib/fluent/plugin/in_dummy.rb +22 -18
- data/lib/fluent/plugin/in_exec.rb +18 -8
- data/lib/fluent/plugin/in_forward.rb +36 -79
- data/lib/fluent/plugin/in_gc_stat.rb +4 -0
- data/lib/fluent/plugin/in_http.rb +21 -18
- data/lib/fluent/plugin/in_monitor_agent.rb +15 -48
- data/lib/fluent/plugin/in_object_space.rb +6 -1
- data/lib/fluent/plugin/in_stream.rb +7 -3
- data/lib/fluent/plugin/in_syslog.rb +46 -95
- data/lib/fluent/plugin/in_tail.rb +51 -595
- data/lib/fluent/plugin/in_tcp.rb +8 -1
- data/lib/fluent/plugin/in_udp.rb +8 -14
- 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_copy.rb +11 -7
- data/lib/fluent/plugin/out_exec.rb +15 -11
- data/lib/fluent/plugin/out_exec_filter.rb +18 -10
- data/lib/fluent/plugin/out_file.rb +34 -5
- data/lib/fluent/plugin/out_forward.rb +19 -9
- data/lib/fluent/plugin/out_null.rb +0 -14
- data/lib/fluent/plugin/out_roundrobin.rb +11 -7
- data/lib/fluent/plugin/out_stdout.rb +5 -7
- data/lib/fluent/plugin/out_stream.rb +3 -1
- data/lib/fluent/plugin/output.rb +979 -0
- data/lib/fluent/plugin/owned_by_mixin.rb +42 -0
- data/lib/fluent/plugin/parser.rb +244 -0
- data/lib/fluent/plugin/parser_apache.rb +24 -0
- data/lib/fluent/plugin/parser_apache2.rb +84 -0
- data/lib/fluent/plugin/parser_apache_error.rb +21 -0
- data/lib/fluent/plugin/parser_csv.rb +31 -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 +102 -0
- data/lib/fluent/plugin/parser_nginx.rb +24 -0
- data/lib/fluent/plugin/parser_none.rb +36 -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 +120 -114
- data/lib/fluent/plugin/storage.rb +84 -0
- data/lib/fluent/plugin/storage_local.rb +116 -0
- data/lib/fluent/plugin/string_util.rb +16 -13
- data/lib/fluent/plugin_helper.rb +39 -0
- data/lib/fluent/plugin_helper/child_process.rb +298 -0
- data/lib/fluent/plugin_helper/compat_parameters.rb +99 -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/retry_state.rb +177 -0
- data/lib/fluent/plugin_helper/storage.rb +308 -0
- data/lib/fluent/plugin_helper/thread.rb +147 -0
- data/lib/fluent/plugin_helper/timer.rb +85 -0
- data/lib/fluent/plugin_id.rb +63 -0
- data/lib/fluent/process.rb +21 -30
- data/lib/fluent/registry.rb +21 -9
- data/lib/fluent/root_agent.rb +115 -40
- data/lib/fluent/supervisor.rb +330 -320
- data/lib/fluent/system_config.rb +42 -18
- data/lib/fluent/test.rb +6 -1
- data/lib/fluent/test/base.rb +23 -3
- data/lib/fluent/test/driver/base.rb +247 -0
- data/lib/fluent/test/driver/event_feeder.rb +98 -0
- data/lib/fluent/test/driver/filter.rb +35 -0
- data/lib/fluent/test/driver/input.rb +31 -0
- data/lib/fluent/test/driver/output.rb +78 -0
- data/lib/fluent/test/driver/test_event_router.rb +45 -0
- data/lib/fluent/test/filter_test.rb +0 -1
- data/lib/fluent/test/formatter_test.rb +2 -1
- data/lib/fluent/test/input_test.rb +23 -17
- data/lib/fluent/test/output_test.rb +28 -39
- data/lib/fluent/test/parser_test.rb +1 -1
- data/lib/fluent/time.rb +104 -1
- data/lib/fluent/{status.rb → unique_id.rb} +15 -24
- data/lib/fluent/version.rb +1 -1
- data/lib/fluent/winsvc.rb +72 -0
- data/test/compat/test_calls_super.rb +164 -0
- data/test/config/test_config_parser.rb +83 -0
- data/test/config/test_configurable.rb +547 -274
- data/test/config/test_configure_proxy.rb +146 -29
- data/test/config/test_dsl.rb +3 -181
- data/test/config/test_element.rb +274 -0
- data/test/config/test_literal_parser.rb +1 -1
- data/test/config/test_section.rb +79 -7
- data/test/config/test_system_config.rb +21 -0
- data/test/config/test_types.rb +3 -26
- data/test/helper.rb +78 -8
- data/test/plugin/test_bare_output.rb +118 -0
- data/test/plugin/test_base.rb +75 -0
- data/test/plugin/test_buf_file.rb +420 -521
- data/test/plugin/test_buf_memory.rb +32 -194
- data/test/plugin/test_buffer.rb +981 -0
- data/test/plugin/test_buffer_chunk.rb +110 -0
- data/test/plugin/test_buffer_file_chunk.rb +770 -0
- data/test/plugin/test_buffer_memory_chunk.rb +265 -0
- data/test/plugin/test_filter.rb +255 -0
- data/test/plugin/test_filter_grep.rb +2 -73
- data/test/plugin/test_filter_record_transformer.rb +24 -68
- data/test/plugin/test_filter_stdout.rb +6 -6
- data/test/plugin/test_in_debug_agent.rb +2 -0
- data/test/plugin/test_in_dummy.rb +11 -17
- data/test/plugin/test_in_exec.rb +6 -25
- data/test/plugin/test_in_forward.rb +112 -151
- data/test/plugin/test_in_gc_stat.rb +2 -0
- data/test/plugin/test_in_http.rb +106 -157
- data/test/plugin/test_in_object_space.rb +21 -5
- data/test/plugin/test_in_stream.rb +14 -13
- data/test/plugin/test_in_syslog.rb +30 -275
- data/test/plugin/test_in_tail.rb +95 -234
- data/test/plugin/test_in_tcp.rb +14 -0
- data/test/plugin/test_in_udp.rb +21 -13
- 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_copy.rb +15 -2
- data/test/plugin/test_out_exec.rb +75 -25
- data/test/plugin/test_out_exec_filter.rb +74 -8
- data/test/plugin/test_out_file.rb +61 -7
- data/test/plugin/test_out_forward.rb +92 -15
- data/test/plugin/test_out_roundrobin.rb +1 -0
- data/test/plugin/test_out_stdout.rb +22 -13
- data/test/plugin/test_out_stream.rb +18 -0
- data/test/plugin/test_output.rb +515 -0
- data/test/plugin/test_output_as_buffered.rb +1540 -0
- data/test/plugin/test_output_as_buffered_overflow.rb +247 -0
- data/test/plugin/test_output_as_buffered_retries.rb +808 -0
- data/test/plugin/test_output_as_buffered_secondary.rb +776 -0
- data/test/plugin/test_output_as_standard.rb +362 -0
- data/test/plugin/test_owned_by.rb +35 -0
- data/test/plugin/test_storage.rb +167 -0
- data/test/plugin/test_storage_local.rb +8 -0
- data/test/plugin_helper/test_child_process.rb +599 -0
- data/test/plugin_helper/test_compat_parameters.rb +175 -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_retry_state.rb +399 -0
- data/test/plugin_helper/test_storage.rb +411 -0
- data/test/plugin_helper/test_thread.rb +164 -0
- data/test/plugin_helper/test_timer.rb +100 -0
- data/test/scripts/exec_script.rb +0 -6
- data/test/scripts/fluent/plugin/out_test.rb +3 -0
- data/test/test_config.rb +13 -4
- data/test/test_event.rb +24 -13
- data/test/test_event_router.rb +8 -7
- data/test/test_event_time.rb +187 -0
- data/test/test_formatter.rb +13 -51
- data/test/test_input.rb +1 -1
- data/test/test_log.rb +239 -16
- data/test/test_mixin.rb +1 -1
- data/test/test_output.rb +53 -66
- data/test/test_parser.rb +105 -323
- data/test/test_plugin_helper.rb +81 -0
- data/test/test_root_agent.rb +4 -52
- data/test/test_supervisor.rb +272 -0
- data/test/test_unique_id.rb +47 -0
- metadata +180 -54
- data/lib/fluent/buffer.rb +0 -365
- data/lib/fluent/plugin/filter_parser.rb +0 -107
- data/lib/fluent/plugin/in_status.rb +0 -76
- data/lib/fluent/test/helpers.rb +0 -86
- data/test/plugin/data/log/foo/bar2 +0 -0
- data/test/plugin/test_filter_parser.rb +0 -744
- data/test/plugin/test_in_status.rb +0 -38
- data/test/test_buffer.rb +0 -624
data/lib/fluent/input.rb
CHANGED
@@ -14,38 +14,8 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
-
require 'fluent/
|
18
|
-
require 'fluent/configurable'
|
19
|
-
require 'fluent/engine'
|
20
|
-
require 'fluent/log'
|
17
|
+
require 'fluent/compat/input'
|
21
18
|
|
22
19
|
module Fluent
|
23
|
-
|
24
|
-
include Configurable
|
25
|
-
include PluginId
|
26
|
-
include PluginLoggerMixin
|
27
|
-
|
28
|
-
attr_accessor :router
|
29
|
-
|
30
|
-
def initialize
|
31
|
-
super
|
32
|
-
end
|
33
|
-
|
34
|
-
def configure(conf)
|
35
|
-
super
|
36
|
-
|
37
|
-
if label_name = conf['@label']
|
38
|
-
label = Engine.root_agent.find_label(label_name)
|
39
|
-
@router = label.event_router
|
40
|
-
elsif @router.nil?
|
41
|
-
@router = Engine.root_agent.event_router
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def start
|
46
|
-
end
|
47
|
-
|
48
|
-
def shutdown
|
49
|
-
end
|
50
|
-
end
|
20
|
+
Input = Fluent::Compat::Input
|
51
21
|
end
|
data/lib/fluent/label.rb
CHANGED
data/lib/fluent/load.rb
CHANGED
@@ -9,16 +9,18 @@ require 'json'
|
|
9
9
|
require 'yajl'
|
10
10
|
require 'uri'
|
11
11
|
require 'msgpack'
|
12
|
+
require 'strptime'
|
12
13
|
begin
|
13
14
|
require 'sigdump/setup'
|
14
15
|
rescue
|
15
16
|
# ignore setup error on Win or similar platform which doesn't support signal
|
16
17
|
end
|
17
18
|
require 'cool.io'
|
19
|
+
|
20
|
+
require 'fluent/time'
|
18
21
|
require 'fluent/env'
|
19
22
|
require 'fluent/version'
|
20
23
|
require 'fluent/log'
|
21
|
-
require 'fluent/status'
|
22
24
|
require 'fluent/config'
|
23
25
|
require 'fluent/engine'
|
24
26
|
require 'fluent/rpc'
|
@@ -28,7 +30,6 @@ require 'fluent/plugin'
|
|
28
30
|
require 'fluent/parser'
|
29
31
|
require 'fluent/formatter'
|
30
32
|
require 'fluent/event'
|
31
|
-
require 'fluent/buffer'
|
32
33
|
require 'fluent/input'
|
33
34
|
require 'fluent/output'
|
34
35
|
require 'fluent/filter'
|
data/lib/fluent/log.rb
CHANGED
@@ -53,9 +53,34 @@ module Fluent
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
def initialize(
|
57
|
-
|
58
|
-
|
56
|
+
def initialize(logger, opts={})
|
57
|
+
# overwrites logger.level= so that config reloading resets level of Fluentd::Log
|
58
|
+
orig_logger_level_setter = logger.class.public_instance_method(:level=).bind(logger)
|
59
|
+
me = self
|
60
|
+
# The original ruby logger sets the number as each log level like below.
|
61
|
+
# DEBUG = 0
|
62
|
+
# INFO = 1
|
63
|
+
# WARN = 2
|
64
|
+
# ERROR = 3
|
65
|
+
# FATAL = 4
|
66
|
+
# Serverengine use this original log number. In addition to this, serverengine sets -1 as TRACE level.
|
67
|
+
# TRACE = -1
|
68
|
+
#
|
69
|
+
# On the other hand, in fluentd side, it sets the number like below.
|
70
|
+
# TRACE = 0
|
71
|
+
# DEBUG = 1
|
72
|
+
# INFO = 2
|
73
|
+
# WARN = 3
|
74
|
+
# ERROR = 4
|
75
|
+
# FATAL = 5
|
76
|
+
#
|
77
|
+
# Then fluentd's level is set as serverengine's level + 1.
|
78
|
+
# So if serverengine's logger level is changed, fluentd's log level will be changed to that + 1.
|
79
|
+
logger.define_singleton_method(:level=) {|level| orig_logger_level_setter.call(level); me.level = self.level + 1 }
|
80
|
+
|
81
|
+
@logger = logger
|
82
|
+
@out = logger.instance_variable_get(:@logdev)
|
83
|
+
@level = logger.level + 1
|
59
84
|
@debug_mode = false
|
60
85
|
@self_event = false
|
61
86
|
@tag = 'fluent'
|
@@ -67,16 +92,40 @@ module Fluent
|
|
67
92
|
|
68
93
|
# Fluent::Engine requires Fluent::Log, so we must take that object lazily
|
69
94
|
@engine = Fluent.const_get('Engine')
|
95
|
+
@optional_header = nil
|
96
|
+
@optional_attrs = nil
|
70
97
|
|
71
|
-
|
72
|
-
|
73
|
-
|
98
|
+
@suppress_repeated_stacktrace = opts[:suppress_repeated_stacktrace]
|
99
|
+
end
|
100
|
+
|
101
|
+
def dup
|
102
|
+
dl_opts = {}
|
103
|
+
dl_opts[:log_level] = @level - 1
|
104
|
+
logger = ServerEngine::DaemonLogger.new(@out, dl_opts)
|
105
|
+
clone = self.class.new(logger, suppress_repeated_stacktrace: @suppress_repeated_stacktrace)
|
106
|
+
clone.tag = @tag
|
107
|
+
clone.time_format = @time_format
|
108
|
+
# optional headers/attrs are not copied, because new PluginLogger should have another one of it
|
109
|
+
clone
|
74
110
|
end
|
75
111
|
|
76
112
|
attr_accessor :out
|
77
113
|
attr_accessor :level
|
78
114
|
attr_accessor :tag
|
79
115
|
attr_accessor :time_format
|
116
|
+
attr_accessor :optional_header, :optional_attrs
|
117
|
+
|
118
|
+
def logdev=(logdev)
|
119
|
+
@out = logdev
|
120
|
+
@logger.instance_variable_set(:@logdev, logdev)
|
121
|
+
nil
|
122
|
+
end
|
123
|
+
|
124
|
+
def reopen!
|
125
|
+
# do noting in @logger.reopen! because it's already reopened in Supervisor.load_config
|
126
|
+
@logger.reopen! if @logger
|
127
|
+
nil
|
128
|
+
end
|
80
129
|
|
81
130
|
def enable_debug(b=true)
|
82
131
|
@debug_mode = b
|
@@ -229,7 +278,7 @@ module Fluent
|
|
229
278
|
end
|
230
279
|
|
231
280
|
def puts(msg)
|
232
|
-
@
|
281
|
+
@logger << msg + "\n"
|
233
282
|
@out.flush
|
234
283
|
msg
|
235
284
|
rescue
|
@@ -240,18 +289,38 @@ module Fluent
|
|
240
289
|
def write(data)
|
241
290
|
@out.write(data)
|
242
291
|
end
|
243
|
-
# We need `#<<` method to use this logger class with other
|
244
|
-
# libraries such as aws-sdk
|
245
|
-
alias << write
|
246
292
|
|
247
293
|
def flush
|
248
294
|
@out.flush
|
249
295
|
end
|
250
296
|
|
297
|
+
def reset
|
298
|
+
@out.reset if @out.respond_to?(:reset)
|
299
|
+
end
|
300
|
+
|
301
|
+
private
|
302
|
+
|
303
|
+
def dump_stacktrace(backtrace, level)
|
304
|
+
return if @level > level
|
305
|
+
|
306
|
+
time = Time.now
|
307
|
+
line = caller_line(time, 5, level)
|
308
|
+
if @suppress_repeated_stacktrace && (Thread.current[:last_repeated_stacktrace] == backtrace)
|
309
|
+
puts [" ", line, 'suppressed same stacktrace'].join
|
310
|
+
else
|
311
|
+
backtrace.each { |msg|
|
312
|
+
puts [" ", line, msg].join
|
313
|
+
}
|
314
|
+
Thread.current[:last_repeated_stacktrace] = backtrace if @suppress_repeated_stacktrace
|
315
|
+
end
|
316
|
+
|
317
|
+
nil
|
318
|
+
end
|
319
|
+
|
251
320
|
def event(level, args)
|
252
321
|
time = Time.now
|
253
|
-
message = ''
|
254
|
-
map = {}
|
322
|
+
message = @optional_header ? @optional_header.dup : ''
|
323
|
+
map = @optional_attrs ? @optional_attrs.dup : {}
|
255
324
|
args.each {|a|
|
256
325
|
if a.is_a?(Hash)
|
257
326
|
a.each_pair {|k,v|
|
@@ -263,7 +332,11 @@ module Fluent
|
|
263
332
|
}
|
264
333
|
|
265
334
|
map.each_pair {|k,v|
|
266
|
-
|
335
|
+
if k == "error".freeze && v.is_a?(Exception) && !map.has_key?("error_class")
|
336
|
+
message << " error_class=#{v.class.to_s} error=#{v.to_s.inspect}"
|
337
|
+
else
|
338
|
+
message << " #{k}=#{v.inspect}"
|
339
|
+
end
|
267
340
|
}
|
268
341
|
|
269
342
|
unless @threads_exclude_events.include?(Thread.current)
|
@@ -291,25 +364,6 @@ module Fluent
|
|
291
364
|
end
|
292
365
|
return log_msg
|
293
366
|
end
|
294
|
-
|
295
|
-
private
|
296
|
-
|
297
|
-
def dump_stacktrace(backtrace, level)
|
298
|
-
return if @level > level
|
299
|
-
|
300
|
-
time = Time.now
|
301
|
-
line = caller_line(time, 5, level)
|
302
|
-
if @suppress_repeated_stacktrace && (Thread.current[:last_repeated_stacktrace] == backtrace)
|
303
|
-
puts [" ", line, 'suppressed same stacktrace'].join
|
304
|
-
else
|
305
|
-
backtrace.each { |msg|
|
306
|
-
puts [" ", line, msg].join
|
307
|
-
}
|
308
|
-
Thread.current[:last_repeated_stacktrace] = backtrace if @suppress_repeated_stacktrace
|
309
|
-
end
|
310
|
-
|
311
|
-
nil
|
312
|
-
end
|
313
367
|
end
|
314
368
|
|
315
369
|
|
@@ -323,7 +377,9 @@ module Fluent
|
|
323
377
|
@logger = logger
|
324
378
|
@level = @logger.level
|
325
379
|
@depth_offset = 2
|
326
|
-
|
380
|
+
if logger.instance_variable_defined?(:@suppress_repeated_stacktrace)
|
381
|
+
@suppress_repeated_stacktrace = logger.instance_variable_get(:@suppress_repeated_stacktrace)
|
382
|
+
end
|
327
383
|
|
328
384
|
enable_color @logger.enable_color?
|
329
385
|
end
|
@@ -342,7 +398,8 @@ module Fluent
|
|
342
398
|
extend Forwardable
|
343
399
|
def_delegators '@logger', :enable_color?, :enable_debug, :enable_event,
|
344
400
|
:disable_events, :tag, :tag=, :time_format, :time_format=,
|
345
|
-
:event, :caller_line, :puts, :write,
|
401
|
+
:event, :caller_line, :puts, :write, :flush, :reset, :out, :out=,
|
402
|
+
:optional_header, :optional_header=, :optional_attrs, :optional_attrs=
|
346
403
|
end
|
347
404
|
|
348
405
|
|
@@ -350,7 +407,7 @@ module Fluent
|
|
350
407
|
def self.included(klass)
|
351
408
|
klass.instance_eval {
|
352
409
|
desc 'Allows the user to set different levels of logging for each plugin.'
|
353
|
-
config_param
|
410
|
+
config_param :@log_level, :string, default: nil, alias: :log_level # 'log_level' will be warned as deprecated
|
354
411
|
}
|
355
412
|
end
|
356
413
|
|
@@ -365,12 +422,24 @@ module Fluent
|
|
365
422
|
def configure(conf)
|
366
423
|
super
|
367
424
|
|
368
|
-
if @log_level
|
425
|
+
if level = conf['@log_level']
|
369
426
|
unless @log.is_a?(PluginLogger)
|
370
|
-
@log = PluginLogger.new($log)
|
427
|
+
@log = PluginLogger.new($log.dup)
|
371
428
|
end
|
372
|
-
@log.level =
|
429
|
+
@log.level = level
|
430
|
+
@log.optional_header = "[#{self.class.name}#{plugin_id_configured? ? "(" + @id + ")" : ""}] "
|
431
|
+
@log.optional_attrs = {}
|
373
432
|
end
|
374
433
|
end
|
434
|
+
|
435
|
+
def start
|
436
|
+
@log.reset
|
437
|
+
super
|
438
|
+
end
|
439
|
+
|
440
|
+
def terminate
|
441
|
+
super
|
442
|
+
@log.reset
|
443
|
+
end
|
375
444
|
end
|
376
445
|
end
|
data/lib/fluent/match.rb
CHANGED
@@ -15,42 +15,6 @@
|
|
15
15
|
#
|
16
16
|
|
17
17
|
module Fluent
|
18
|
-
class Match
|
19
|
-
def initialize(pattern_str, output)
|
20
|
-
patterns = pattern_str.split(/\s+/).map {|str|
|
21
|
-
MatchPattern.create(str)
|
22
|
-
}
|
23
|
-
if patterns.length == 1
|
24
|
-
@pattern = patterns[0]
|
25
|
-
else
|
26
|
-
@pattern = OrMatchPattern.new(patterns)
|
27
|
-
end
|
28
|
-
@output = output
|
29
|
-
end
|
30
|
-
|
31
|
-
attr_reader :output
|
32
|
-
|
33
|
-
def emit(tag, es)
|
34
|
-
chain = NullOutputChain.instance
|
35
|
-
@output.emit(tag, es, chain)
|
36
|
-
end
|
37
|
-
|
38
|
-
def start
|
39
|
-
@output.start
|
40
|
-
end
|
41
|
-
|
42
|
-
def shutdown
|
43
|
-
@output.shutdown
|
44
|
-
end
|
45
|
-
|
46
|
-
def match(tag)
|
47
|
-
if @pattern.match(tag)
|
48
|
-
return true
|
49
|
-
end
|
50
|
-
return false
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
18
|
class MatchPattern
|
55
19
|
def self.create(str)
|
56
20
|
if str == '**'
|
data/lib/fluent/mixin.rb
CHANGED
@@ -26,6 +26,16 @@ module Fluent
|
|
26
26
|
@tc2 = 0
|
27
27
|
@tc2_str = nil
|
28
28
|
|
29
|
+
if format && format =~ /(^|[^%])(%%)*%L|(^|[^%])(%%)*%\d*N/
|
30
|
+
define_singleton_method(:format) {|time|
|
31
|
+
format_with_subsec(time)
|
32
|
+
}
|
33
|
+
else
|
34
|
+
define_singleton_method(:format) {|time|
|
35
|
+
format_without_subsec(time)
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
29
39
|
if formatter = Fluent::Timezone.formatter(timezone, format)
|
30
40
|
define_singleton_method(:format_nocache) {|time|
|
31
41
|
formatter.call(time)
|
@@ -56,7 +66,7 @@ module Fluent
|
|
56
66
|
end
|
57
67
|
end
|
58
68
|
|
59
|
-
def
|
69
|
+
def format_without_subsec(time)
|
60
70
|
if @tc1 == time
|
61
71
|
return @tc1_str
|
62
72
|
elsif @tc2 == time
|
@@ -74,6 +84,28 @@ module Fluent
|
|
74
84
|
end
|
75
85
|
end
|
76
86
|
|
87
|
+
def format_with_subsec(time)
|
88
|
+
if Fluent::EventTime.eq?(@tc1, time)
|
89
|
+
return @tc1_str
|
90
|
+
elsif Fluent::EventTime.eq?(@tc2, time)
|
91
|
+
return @tc2_str
|
92
|
+
else
|
93
|
+
str = format_nocache(time)
|
94
|
+
if @tc1 < @tc2
|
95
|
+
@tc1 = time
|
96
|
+
@tc1_str = str
|
97
|
+
else
|
98
|
+
@tc2 = time
|
99
|
+
@tc2_str = str
|
100
|
+
end
|
101
|
+
return str
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def format(time)
|
106
|
+
# will be overridden in initialize
|
107
|
+
end
|
108
|
+
|
77
109
|
def format_nocache(time)
|
78
110
|
# will be overridden in initialize
|
79
111
|
end
|
@@ -101,13 +133,18 @@ module Fluent
|
|
101
133
|
attr_accessor :remove_tag_prefix, :remove_tag_suffix, :add_tag_prefix, :add_tag_suffix
|
102
134
|
def configure(conf)
|
103
135
|
super
|
104
|
-
if remove_tag_prefix = conf['remove_tag_prefix']
|
105
|
-
@remove_tag_prefix = Regexp.new('^' + Regexp.escape(remove_tag_prefix))
|
106
|
-
end
|
107
136
|
|
108
|
-
|
109
|
-
|
110
|
-
|
137
|
+
@remove_tag_prefix = if conf.has_key?('remove_tag_prefix')
|
138
|
+
Regexp.new('^' + Regexp.escape(conf['remove_tag_prefix']))
|
139
|
+
else
|
140
|
+
nil
|
141
|
+
end
|
142
|
+
|
143
|
+
@remove_tag_suffix = if conf.has_key?('remove_tag_suffix')
|
144
|
+
Regexp.new(Regexp.escape(conf['remove_tag_suffix']) + '$')
|
145
|
+
else
|
146
|
+
nil
|
147
|
+
end
|
111
148
|
|
112
149
|
@add_tag_prefix = conf['add_tag_prefix']
|
113
150
|
@add_tag_suffix = conf['add_tag_suffix']
|
@@ -130,6 +167,8 @@ module Fluent
|
|
130
167
|
|
131
168
|
def configure(conf)
|
132
169
|
@include_time_key = false
|
170
|
+
@localtime = false
|
171
|
+
@timezone = nil
|
133
172
|
|
134
173
|
super
|
135
174
|
|
@@ -192,4 +231,75 @@ module Fluent
|
|
192
231
|
record[@tag_key] = tag if @include_tag_key
|
193
232
|
end
|
194
233
|
end
|
234
|
+
|
235
|
+
module TypeConverter
|
236
|
+
Converters = {
|
237
|
+
'string' => lambda { |v| v.to_s },
|
238
|
+
'integer' => lambda { |v| v.to_i },
|
239
|
+
'float' => lambda { |v| v.to_f },
|
240
|
+
'bool' => lambda { |v|
|
241
|
+
case v.downcase
|
242
|
+
when 'true', 'yes', '1'
|
243
|
+
true
|
244
|
+
else
|
245
|
+
false
|
246
|
+
end
|
247
|
+
},
|
248
|
+
'time' => lambda { |v, time_parser|
|
249
|
+
time_parser.parse(v)
|
250
|
+
},
|
251
|
+
'array' => lambda { |v, delimiter|
|
252
|
+
v.to_s.split(delimiter)
|
253
|
+
}
|
254
|
+
}
|
255
|
+
|
256
|
+
def self.included(klass)
|
257
|
+
klass.instance_eval {
|
258
|
+
config_param :types, :string, default: nil
|
259
|
+
config_param :types_delimiter, :string, default: ','
|
260
|
+
config_param :types_label_delimiter, :string, default: ':'
|
261
|
+
}
|
262
|
+
end
|
263
|
+
|
264
|
+
def configure(conf)
|
265
|
+
super
|
266
|
+
|
267
|
+
@type_converters = nil
|
268
|
+
@type_converters = parse_types_parameter unless @types.nil?
|
269
|
+
end
|
270
|
+
|
271
|
+
private
|
272
|
+
|
273
|
+
def convert_type(name, value)
|
274
|
+
converter = @type_converters[name]
|
275
|
+
converter.nil? ? value : converter.call(value)
|
276
|
+
end
|
277
|
+
|
278
|
+
def parse_types_parameter
|
279
|
+
converters = {}
|
280
|
+
|
281
|
+
@types.split(@types_delimiter).each { |pattern_name|
|
282
|
+
name, type, format = pattern_name.split(@types_label_delimiter, 3)
|
283
|
+
raise ConfigError, "Type is needed" if type.nil?
|
284
|
+
|
285
|
+
case type
|
286
|
+
when 'time'
|
287
|
+
require 'fluent/parser'
|
288
|
+
t_parser = Fluent::TextParser::TimeParser.new(format)
|
289
|
+
converters[name] = lambda { |v|
|
290
|
+
Converters[type].call(v, t_parser)
|
291
|
+
}
|
292
|
+
when 'array'
|
293
|
+
delimiter = format || ','
|
294
|
+
converters[name] = lambda { |v|
|
295
|
+
Converters[type].call(v, delimiter)
|
296
|
+
}
|
297
|
+
else
|
298
|
+
converters[name] = Converters[type]
|
299
|
+
end
|
300
|
+
}
|
301
|
+
|
302
|
+
converters
|
303
|
+
end
|
304
|
+
end
|
195
305
|
end
|