fluentd 0.12.20 → 0.12.21

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fluentd might be problematic. Click here for more details.

Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +23 -0
  3. data/Rakefile +2 -2
  4. data/bin/fluent-debug +0 -1
  5. data/lib/fluent/agent.rb +12 -9
  6. data/lib/fluent/buffer.rb +9 -3
  7. data/lib/fluent/command/bundler_injection.rb +2 -0
  8. data/lib/fluent/command/cat.rb +1 -1
  9. data/lib/fluent/command/debug.rb +3 -2
  10. data/lib/fluent/command/fluentd.rb +3 -1
  11. data/lib/fluent/config.rb +4 -5
  12. data/lib/fluent/config/basic_parser.rb +3 -4
  13. data/lib/fluent/config/configure_proxy.rb +2 -0
  14. data/lib/fluent/config/dsl.rb +3 -0
  15. data/lib/fluent/config/element.rb +3 -2
  16. data/lib/fluent/config/literal_parser.rb +8 -5
  17. data/lib/fluent/config/parser.rb +5 -3
  18. data/lib/fluent/config/section.rb +3 -3
  19. data/lib/fluent/config/types.rb +44 -50
  20. data/lib/fluent/config/v1_parser.rb +8 -6
  21. data/lib/fluent/configurable.rb +8 -6
  22. data/lib/fluent/engine.rb +23 -11
  23. data/lib/fluent/event.rb +2 -0
  24. data/lib/fluent/event_router.rb +4 -2
  25. data/lib/fluent/filter.rb +6 -0
  26. data/lib/fluent/formatter.rb +27 -25
  27. data/lib/fluent/input.rb +5 -0
  28. data/lib/fluent/label.rb +2 -2
  29. data/lib/fluent/log.rb +5 -2
  30. data/lib/fluent/mixin.rb +4 -2
  31. data/lib/fluent/output.rb +45 -31
  32. data/lib/fluent/parser.rb +35 -25
  33. data/lib/fluent/plugin.rb +4 -0
  34. data/lib/fluent/plugin/buf_file.rb +9 -2
  35. data/lib/fluent/plugin/buf_memory.rb +7 -1
  36. data/lib/fluent/plugin/exec_util.rb +7 -2
  37. data/lib/fluent/plugin/filter_grep.rb +6 -3
  38. data/lib/fluent/plugin/filter_record_transformer.rb +52 -51
  39. data/lib/fluent/plugin/filter_stdout.rb +4 -1
  40. data/lib/fluent/plugin/in_debug_agent.rb +7 -5
  41. data/lib/fluent/plugin/in_dummy.rb +8 -3
  42. data/lib/fluent/plugin/in_exec.rb +16 -10
  43. data/lib/fluent/plugin/in_forward.rb +18 -11
  44. data/lib/fluent/plugin/in_gc_stat.rb +6 -2
  45. data/lib/fluent/plugin/in_http.rb +23 -14
  46. data/lib/fluent/plugin/in_monitor_agent.rb +24 -17
  47. data/lib/fluent/plugin/in_object_space.rb +9 -4
  48. data/lib/fluent/plugin/in_stream.rb +15 -6
  49. data/lib/fluent/plugin/in_syslog.rb +18 -12
  50. data/lib/fluent/plugin/in_tail.rb +61 -40
  51. data/lib/fluent/plugin/in_tcp.rb +3 -1
  52. data/lib/fluent/plugin/in_udp.rb +1 -1
  53. data/lib/fluent/plugin/out_copy.rb +5 -1
  54. data/lib/fluent/plugin/out_exec.rb +9 -6
  55. data/lib/fluent/plugin/out_exec_filter.rb +32 -25
  56. data/lib/fluent/plugin/out_file.rb +11 -5
  57. data/lib/fluent/plugin/out_forward.rb +30 -24
  58. data/lib/fluent/plugin/out_null.rb +2 -0
  59. data/lib/fluent/plugin/out_relabel.rb +2 -0
  60. data/lib/fluent/plugin/out_roundrobin.rb +3 -0
  61. data/lib/fluent/plugin/out_stdout.rb +3 -1
  62. data/lib/fluent/plugin/out_stream.rb +8 -8
  63. data/lib/fluent/plugin/socket_util.rb +12 -10
  64. data/lib/fluent/process.rb +14 -8
  65. data/lib/fluent/registry.rb +2 -2
  66. data/lib/fluent/root_agent.rb +16 -12
  67. data/lib/fluent/rpc.rb +7 -7
  68. data/lib/fluent/supervisor.rb +35 -69
  69. data/lib/fluent/system_config.rb +98 -0
  70. data/lib/fluent/test.rb +1 -1
  71. data/lib/fluent/test/base.rb +6 -1
  72. data/lib/fluent/test/filter_test.rb +4 -0
  73. data/lib/fluent/test/formatter_test.rb +3 -2
  74. data/lib/fluent/test/input_test.rb +6 -0
  75. data/lib/fluent/test/output_test.rb +4 -0
  76. data/lib/fluent/test/parser_test.rb +3 -2
  77. data/lib/fluent/timezone.rb +2 -0
  78. data/lib/fluent/version.rb +1 -1
  79. data/test/config/test_configurable.rb +11 -11
  80. data/test/config/test_configure_proxy.rb +1 -1
  81. data/test/config/test_system_config.rb +5 -5
  82. data/test/config/test_types.rb +70 -0
  83. data/test/plugin/test_filter_record_transformer.rb +72 -55
  84. data/test/plugin/test_in_forward.rb +4 -0
  85. data/test/plugin/test_in_tail.rb +73 -2
  86. data/test/test_config.rb +2 -2
  87. data/test/test_event_router.rb +1 -0
  88. data/test/test_output.rb +27 -3
  89. data/test/test_plugin_classes.rb +3 -0
  90. data/test/test_process.rb +1 -0
  91. data/test/test_root_agent.rb +5 -3
  92. metadata +3 -2
@@ -14,14 +14,16 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- module Fluent
18
- module Config
17
+ require 'strscan'
18
+ require 'uri'
19
19
 
20
- require 'strscan'
21
- require 'fluent/config/error'
22
- require 'fluent/config/literal_parser'
23
- require 'fluent/config/element'
20
+ require 'fluent/config/error'
21
+ require 'fluent/config/basic_parser'
22
+ require 'fluent/config/literal_parser'
23
+ require 'fluent/config/element'
24
24
 
25
+ module Fluent
26
+ module Config
25
27
  class V1Parser < LiteralParser
26
28
  ELEMENT_NAME = /[a-zA-Z0-9_]+/
27
29
 
@@ -14,12 +14,14 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- module Fluent
18
- require 'fluent/config/configure_proxy'
19
- require 'fluent/config/section'
20
- require 'fluent/config/error'
21
- require 'fluent/registry'
17
+ require 'fluent/config/configure_proxy'
18
+ require 'fluent/config/section'
19
+ require 'fluent/config/error'
20
+ require 'fluent/registry'
21
+ require 'fluent/plugin'
22
+ require 'fluent/mixin'
22
23
 
24
+ module Fluent
23
25
  module Configurable
24
26
  def self.included(mod)
25
27
  mod.extend(ClassMethods)
@@ -51,7 +53,7 @@ module Fluent
51
53
  conf.corresponding_proxies << proxy
52
54
 
53
55
  # In the nested section, can't get plugin class through proxies so get plugin class here
54
- plugin_class = Plugin.lookup_name_from_class(proxy.name.to_s)
56
+ plugin_class = Fluent::Plugin.lookup_name_from_class(proxy.name.to_s)
55
57
  root = Fluent::Config::SectionGenerator.generate(proxy, conf, logger, plugin_class)
56
58
  @config_root_section = root
57
59
 
@@ -14,11 +14,20 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- module Fluent
18
- require 'fluent/event_router'
19
- require 'fluent/root_agent'
20
- require 'fluent/time'
17
+ require 'socket'
18
+
19
+ require 'msgpack'
20
+ require 'cool.io'
21
+
22
+ require 'fluent/config'
23
+ require 'fluent/event'
24
+ require 'fluent/event_router'
25
+ require 'fluent/root_agent'
26
+ require 'fluent/time'
27
+ require 'fluent/system_config'
28
+ require 'fluent/plugin'
21
29
 
30
+ module Fluent
22
31
  class EngineClass
23
32
  class DummyMessagePackFactory
24
33
  def packer(*args)
@@ -51,8 +60,11 @@ module Fluent
51
60
  attr_reader :root_agent
52
61
  attr_reader :matches, :sources
53
62
  attr_reader :msgpack_factory
63
+ attr_reader :system_config
64
+
65
+ def init(system_config)
66
+ @system_config = system_config
54
67
 
55
- def init(opts = {})
56
68
  BasicSocket.do_not_reverse_lookup = true
57
69
  Plugin.load_plugins
58
70
  if defined?(Encoding)
@@ -60,11 +72,11 @@ module Fluent
60
72
  Encoding.default_external = 'ASCII-8BIT' if Encoding.respond_to?(:default_external)
61
73
  end
62
74
 
63
- suppress_interval(opts[:suppress_interval]) if opts[:suppress_interval]
64
- @suppress_config_dump = opts[:suppress_config_dump] if opts[:suppress_config_dump]
65
- @without_source = opts[:without_source] if opts[:without_source]
75
+ suppress_interval(system_config.emit_error_log_interval) unless system_config.emit_error_log_interval.nil?
76
+ @suppress_config_dump = system_config.suppress_config_dump unless system_config.suppress_config_dump.nil?
77
+ @without_source = system_config.without_source unless system_config.without_source.nil?
66
78
 
67
- @root_agent = RootAgent.new(opts)
79
+ @root_agent = RootAgent.new(@system_config)
68
80
 
69
81
  self
70
82
  end
@@ -164,7 +176,7 @@ module Fluent
164
176
  begin
165
177
  @event_router.emit(tag, time, record)
166
178
  rescue => e
167
- $log.error "failed to emit fluentd's log event", :tag => tag, :event => record, :error_class => e.class, :error => e
179
+ $log.error "failed to emit fluentd's log event", tag: tag, event: record, error_class: e.class, error: e
168
180
  end
169
181
  }
170
182
  end
@@ -193,7 +205,7 @@ module Fluent
193
205
  end
194
206
 
195
207
  rescue => e
196
- $log.error "unexpected error", :error_class=>e.class, :error=>e
208
+ $log.error "unexpected error", error_class: e.class, error: e
197
209
  $log.error_backtrace
198
210
  ensure
199
211
  $log.info "shutting down fluentd"
@@ -14,6 +14,8 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
+ require 'fluent/engine'
18
+
17
19
  module Fluent
18
20
  class EventStream
19
21
  include Enumerable
@@ -13,9 +13,11 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
  #
16
- module Fluent
17
- require 'fluent/match'
18
16
 
17
+ require 'fluent/match'
18
+ require 'fluent/event'
19
+
20
+ module Fluent
19
21
  #
20
22
  # EventRouter is responsible to route events to a collector.
21
23
  #
@@ -14,6 +14,12 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
+ require 'fluent/config'
18
+ require 'fluent/configurable'
19
+ require 'fluent/engine'
20
+ require 'fluent/event'
21
+ require 'fluent/log'
22
+
17
23
  module Fluent
18
24
  class Filter
19
25
  include Configurable
@@ -14,9 +14,11 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- module Fluent
18
- require 'fluent/registry'
17
+ require 'fluent/configurable'
18
+ require 'fluent/registry'
19
+ require 'fluent/mixin'
19
20
 
21
+ module Fluent
20
22
  class Formatter
21
23
  include Configurable
22
24
 
@@ -33,13 +35,13 @@ module Fluent
33
35
  module HandleTagAndTimeMixin
34
36
  def self.included(klass)
35
37
  klass.instance_eval {
36
- config_param :include_time_key, :bool, :default => false
37
- config_param :time_key, :string, :default => 'time'
38
- config_param :time_format, :string, :default => nil
39
- config_param :include_tag_key, :bool, :default => false
40
- config_param :tag_key, :string, :default => 'tag'
41
- config_param :localtime, :bool, :default => true
42
- config_param :timezone, :string, :default => nil
38
+ config_param :include_time_key, :bool, default: false
39
+ config_param :time_key, :string, default: 'time'
40
+ config_param :time_format, :string, default: nil
41
+ config_param :include_tag_key, :bool, default: false
42
+ config_param :tag_key, :string, default: 'tag'
43
+ config_param :localtime, :bool, default: true
44
+ config_param :timezone, :string, default: nil
43
45
  }
44
46
  end
45
47
 
@@ -65,9 +67,9 @@ module Fluent
65
67
  class OutFileFormatter < Formatter
66
68
  include HandleTagAndTimeMixin
67
69
 
68
- config_param :output_time, :bool, :default => true
69
- config_param :output_tag, :bool, :default => true
70
- config_param :delimiter, :default => "\t" do |val|
70
+ config_param :output_time, :bool, default: true
71
+ config_param :output_tag, :bool, default: true
72
+ config_param :delimiter, default: "\t" do |val|
71
73
  case val
72
74
  when /SPACE/i then ' '
73
75
  when /COMMA/i then ','
@@ -85,7 +87,7 @@ module Fluent
85
87
  end
86
88
 
87
89
  class StdoutFormatter < Formatter
88
- config_param :output_type, :string, :default => 'json'
90
+ config_param :output_type, :string, default: 'json'
89
91
 
90
92
  def configure(conf)
91
93
  super
@@ -103,7 +105,7 @@ module Fluent
103
105
  module StructuredFormatMixin
104
106
  def self.included(klass)
105
107
  klass.instance_eval {
106
- config_param :time_as_epoch, :bool, :default => false
108
+ config_param :time_as_epoch, :bool, default: false
107
109
  }
108
110
  end
109
111
 
@@ -131,7 +133,7 @@ module Fluent
131
133
  include HandleTagAndTimeMixin
132
134
  include StructuredFormatMixin
133
135
 
134
- config_param :json_parser, :string, :default => 'oj'
136
+ config_param :json_parser, :string, default: 'oj'
135
137
 
136
138
  def configure(conf)
137
139
  super
@@ -139,7 +141,7 @@ module Fluent
139
141
  begin
140
142
  raise LoadError unless @json_parser == 'oj'
141
143
  require 'oj'
142
- Oj.default_options = {:mode => :compat}
144
+ Oj.default_options = {mode: :compat}
143
145
  @dump_proc = Oj.method(:dump)
144
146
  rescue LoadError
145
147
  @dump_proc = Yajl.method(:dump)
@@ -172,8 +174,8 @@ module Fluent
172
174
  class LabeledTSVFormatter < Formatter
173
175
  include HandleTagAndTimeMixin
174
176
 
175
- config_param :delimiter, :string, :default => "\t"
176
- config_param :label_delimiter, :string, :default => ":"
177
+ config_param :delimiter, :string, default: "\t"
178
+ config_param :label_delimiter, :string, default: ":"
177
179
 
178
180
  def format(tag, time, record)
179
181
  filter_record(tag, time, record)
@@ -189,11 +191,11 @@ module Fluent
189
191
  class CsvFormatter < Formatter
190
192
  include HandleTagAndTimeMixin
191
193
 
192
- config_param :delimiter, :default => ',' do |val|
194
+ config_param :delimiter, default: ',' do |val|
193
195
  ['\t', 'TAB'].include?(val) ? "\t" : val
194
196
  end
195
- config_param :force_quotes, :bool, :default => true
196
- config_param :fields, :default => [] do |val|
197
+ config_param :force_quotes, :bool, default: true
198
+ config_param :fields, default: [] do |val|
197
199
  val.split(',').map do |f|
198
200
  f.strip!
199
201
  f.size > 0 ? f : nil
@@ -211,14 +213,14 @@ module Fluent
211
213
  memo << record[key]
212
214
  memo
213
215
  end
214
- CSV.generate_line(row, :col_sep => @delimiter,
215
- :force_quotes => @force_quotes)
216
+ CSV.generate_line(row, col_sep: @delimiter,
217
+ force_quotes: @force_quotes)
216
218
  end
217
219
  end
218
220
 
219
221
  class SingleValueFormatter < Formatter
220
- config_param :message_key, :string, :default => 'message'
221
- config_param :add_newline, :bool, :default => true
222
+ config_param :message_key, :string, default: 'message'
223
+ config_param :add_newline, :bool, default: true
222
224
 
223
225
  def format(tag, time, record)
224
226
  text = record[@message_key].to_s.dup
@@ -14,6 +14,11 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
+ require 'fluent/config'
18
+ require 'fluent/configurable'
19
+ require 'fluent/engine'
20
+ require 'fluent/log'
21
+
17
22
  module Fluent
18
23
  class Input
19
24
  include Configurable
@@ -14,9 +14,9 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- module Fluent
18
- require 'fluent/agent'
17
+ require 'fluent/agent'
19
18
 
19
+ module Fluent
20
20
  class Label < Agent
21
21
  def initialize(name, opts = {})
22
22
  super(opts)
@@ -65,6 +65,9 @@ module Fluent
65
65
  # TODO: This variable name is unclear so we should change to better name.
66
66
  @threads_exclude_events = []
67
67
 
68
+ # Fluent::Engine requires Fluent::Log, so we must take that object lazily
69
+ @engine = Fluent.const_get('Engine')
70
+
68
71
  if opts.has_key?(:suppress_repeated_stacktrace)
69
72
  @suppress_repeated_stacktrace = opts[:suppress_repeated_stacktrace]
70
73
  end
@@ -285,7 +288,7 @@ module Fluent
285
288
  record[key] = record[key].inspect unless record[key].respond_to?(:to_msgpack)
286
289
  }
287
290
  record['message'] = message.dup
288
- Engine.push_log_event("#{@tag}.#{level}", time.to_i, record)
291
+ @engine.push_log_event("#{@tag}.#{level}", time.to_i, record)
289
292
  end
290
293
 
291
294
  return time, message
@@ -344,7 +347,7 @@ module Fluent
344
347
  def self.included(klass)
345
348
  klass.instance_eval {
346
349
  desc 'Allows the user to set different levels of logging for each plugin.'
347
- config_param :log_level, :string, :default => nil, :alias => :@log_level
350
+ config_param :log_level, :string, default: nil, alias: :@log_level
348
351
  }
349
352
  end
350
353
 
@@ -14,10 +14,12 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
+ require 'fluent/timezone'
18
+ require 'fluent/time'
19
+ require 'fluent/config/error'
20
+
17
21
  module Fluent
18
22
  class TimeFormatter
19
- require 'fluent/timezone'
20
-
21
23
  def initialize(format, localtime, timezone = nil)
22
24
  @tc1 = 0
23
25
  @tc1_str = nil
@@ -14,6 +14,16 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
+ require 'thread'
18
+
19
+ require 'fluent/config'
20
+ require 'fluent/configurable'
21
+ require 'fluent/engine'
22
+ require 'fluent/log'
23
+ require 'fluent/plugin'
24
+ require 'fluent/status'
25
+ require 'fluent/timezone'
26
+
17
27
  module Fluent
18
28
  class OutputChain
19
29
  def initialize(array, tag, es, chain=NullOutputChain.instance)
@@ -88,12 +98,11 @@ module Fluent
88
98
 
89
99
  def secondary_init(primary)
90
100
  if primary.class != self.class
91
- $log.warn "type of secondary output should be same as primary output", :primary=>primary.class.to_s, :secondary=>self.class.to_s
101
+ $log.warn "type of secondary output should be same as primary output", primary: primary.class.to_s, secondary: self.class.to_s
92
102
  end
93
103
  end
94
104
  end
95
105
 
96
-
97
106
  class OutputThread
98
107
  def initialize(output)
99
108
  @output = output
@@ -152,7 +161,7 @@ module Fluent
152
161
  @mutex.unlock
153
162
  end
154
163
  rescue
155
- $log.error "error on output thread", :error=>$!.to_s
164
+ $log.error "error on output thread", error: $!.to_s
156
165
  $log.error_backtrace
157
166
  raise
158
167
  ensure
@@ -180,22 +189,22 @@ module Fluent
180
189
  end
181
190
 
182
191
  desc 'The buffer type (memory, file)'
183
- config_param :buffer_type, :string, :default => 'memory'
192
+ config_param :buffer_type, :string, default: 'memory'
184
193
  desc 'The interval between data flushes.'
185
- config_param :flush_interval, :time, :default => 60
186
- config_param :try_flush_interval, :float, :default => 1
194
+ config_param :flush_interval, :time, default: 60
195
+ config_param :try_flush_interval, :float, default: 1
187
196
  desc 'If true, the value of `retry_value` is ignored and there is no limit'
188
- config_param :disable_retry_limit, :bool, :default => false
197
+ config_param :disable_retry_limit, :bool, default: false
189
198
  desc 'The limit on the number of retries before buffered data is discarded'
190
- config_param :retry_limit, :integer, :default => 17
199
+ config_param :retry_limit, :integer, default: 17
191
200
  desc 'The initial intervals between write retries.'
192
- config_param :retry_wait, :time, :default => 1.0
201
+ config_param :retry_wait, :time, default: 1.0
193
202
  desc 'The maximum intervals between write retries.'
194
- config_param :max_retry_wait, :time, :default => nil
203
+ config_param :max_retry_wait, :time, default: nil
195
204
  desc 'The number of threads to flush the buffer.'
196
- config_param :num_threads, :integer, :default => 1
205
+ config_param :num_threads, :integer, default: 1
197
206
  desc 'The interval between data flushes for queued chunk.'
198
- config_param :queued_chunk_flush_interval, :time, :default => 1
207
+ config_param :queued_chunk_flush_interval, :time, default: 1
199
208
 
200
209
  def configure(conf)
201
210
  super
@@ -334,7 +343,7 @@ module Fluent
334
343
  @num_errors = 0
335
344
  # Note: don't notify to other threads to prevent
336
345
  # burst to recovered server
337
- $log.warn "retry succeeded.", :plugin_id=>plugin_id
346
+ $log.warn "retry succeeded.", plugin_id: plugin_id
338
347
  end
339
348
 
340
349
  if has_next
@@ -359,20 +368,20 @@ module Fluent
359
368
  end
360
369
 
361
370
  if @disable_retry_limit || error_count < @retry_limit
362
- $log.warn "temporarily failed to flush the buffer.", :next_retry=>Time.at(@next_retry_time), :error_class=>e.class.to_s, :error=>e.to_s, :plugin_id=>plugin_id
371
+ $log.warn "temporarily failed to flush the buffer.", next_retry: Time.at(@next_retry_time), error_class: e.class.to_s, error: e.to_s, plugin_id: plugin_id
363
372
  $log.warn_backtrace e.backtrace
364
373
 
365
374
  elsif @secondary
366
375
  if error_count == @retry_limit
367
- $log.warn "failed to flush the buffer.", :error_class=>e.class.to_s, :error=>e.to_s, :plugin_id=>plugin_id
376
+ $log.warn "failed to flush the buffer.", error_class: e.class.to_s, error: e.to_s, plugin_id: plugin_id
368
377
  $log.warn "retry count exceededs limit. falling back to secondary output."
369
378
  $log.warn_backtrace e.backtrace
370
379
  retry # retry immediately
371
380
  elsif error_count <= @retry_limit + @secondary_limit
372
- $log.warn "failed to flush the buffer, next retry will be with secondary output.", :next_retry=>Time.at(@next_retry_time), :error_class=>e.class.to_s, :error=>e.to_s, :plugin_id=>plugin_id
381
+ $log.warn "failed to flush the buffer, next retry will be with secondary output.", next_retry: Time.at(@next_retry_time), error_class: e.class.to_s, error: e.to_s, plugin_id: plugin_id
373
382
  $log.warn_backtrace e.backtrace
374
383
  else
375
- $log.warn "failed to flush the buffer.", :error_class=>e.class, :error=>e.to_s, :plugin_id=>plugin_id
384
+ $log.warn "failed to flush the buffer.", error_class: e.class, error: e.to_s, plugin_id: plugin_id
376
385
  $log.warn "secondary retry count exceededs limit."
377
386
  $log.warn_backtrace e.backtrace
378
387
  write_abort
@@ -380,7 +389,7 @@ module Fluent
380
389
  end
381
390
 
382
391
  else
383
- $log.warn "failed to flush the buffer.", :error_class=>e.class.to_s, :error=>e.to_s, :plugin_id=>plugin_id
392
+ $log.warn "failed to flush the buffer.", error_class: e.class.to_s, error: e.to_s, plugin_id: plugin_id
384
393
  $log.warn "retry count exceededs limit."
385
394
  $log.warn_backtrace e.backtrace
386
395
  write_abort
@@ -403,7 +412,7 @@ module Fluent
403
412
  begin
404
413
  @buffer.before_shutdown(self)
405
414
  rescue
406
- $log.warn "before_shutdown failed", :error=>$!.to_s
415
+ $log.warn "before_shutdown failed", error: $!.to_s
407
416
  $log.warn_backtrace
408
417
  end
409
418
  end
@@ -425,7 +434,7 @@ module Fluent
425
434
  begin
426
435
  @buffer.clear!
427
436
  rescue
428
- $log.error "unexpected error while aborting", :error=>$!.to_s
437
+ $log.error "unexpected error while aborting", error: $!.to_s
429
438
  $log.error_backtrace
430
439
  end
431
440
  end
@@ -483,11 +492,11 @@ module Fluent
483
492
  end
484
493
 
485
494
  desc 'The time format used as part of the file name.'
486
- config_param :time_slice_format, :string, :default => '%Y%m%d'
495
+ config_param :time_slice_format, :string, default: '%Y%m%d'
487
496
  desc 'The amount of time Fluentd will wait for old logs to arrive.'
488
- config_param :time_slice_wait, :time, :default => 10*60
497
+ config_param :time_slice_wait, :time, default: 10*60
489
498
  desc 'Parse the time value in the specified timezone'
490
- config_param :timezone, :string, :default => nil
499
+ config_param :timezone, :string, default: nil
491
500
  config_set_default :buffer_type, 'file' # overwrite default buffer_type
492
501
  config_set_default :buffer_chunk_limit, 256*1024*1024 # overwrite default buffer_chunk_limit
493
502
  config_set_default :flush_interval, nil
@@ -552,14 +561,20 @@ module Fluent
552
561
  @emit_count += 1
553
562
  formatted_data = {}
554
563
  es.each {|time,record|
555
- tc = time / @time_slice_cache_interval
556
- if @before_tc == tc
557
- key = @before_key
558
- else
559
- @before_tc = tc
560
- key = @time_slicer.call(time)
561
- @before_key = key
564
+ begin
565
+ tc = time / @time_slice_cache_interval
566
+ if @before_tc == tc
567
+ key = @before_key
568
+ else
569
+ @before_tc = tc
570
+ key = @time_slicer.call(time)
571
+ @before_key = key
572
+ end
573
+ rescue => e
574
+ @router.emit_error_event(tag, Engine.now, {'time' => time, 'record' => record}, e)
575
+ next
562
576
  end
577
+
563
578
  formatted_data[key] ||= ''
564
579
  formatted_data[key] << format(tag, time, record)
565
580
  }
@@ -603,4 +618,3 @@ module Fluent
603
618
  #end
604
619
  end
605
620
  end
606
-