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,7 +14,14 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
+ require 'yajl'
18
+
19
+ require 'fluent/output'
20
+ require 'fluent/env'
21
+ require 'fluent/time'
22
+ require 'fluent/timezone'
17
23
  require 'fluent/plugin/exec_util'
24
+ require 'fluent/config/error'
18
25
 
19
26
  module Fluent
20
27
  class ExecFilterOutput < BufferedOutput
@@ -28,61 +35,61 @@ module Fluent
28
35
  desc 'The command (program) to execute.'
29
36
  config_param :command, :string
30
37
 
31
- config_param :remove_prefix, :string, :default => nil
32
- config_param :add_prefix, :string, :default => nil
38
+ config_param :remove_prefix, :string, default: nil
39
+ config_param :add_prefix, :string, default: nil
33
40
 
34
41
  desc "The format used to map the incoming event to the program input.(#{ExecUtil::SUPPORTED_FORMAT.keys.join(',')})"
35
- config_param :in_format, :default => :tsv do |val|
42
+ config_param :in_format, default: :tsv do |val|
36
43
  f = ExecUtil::SUPPORTED_FORMAT[val]
37
44
  raise ConfigError, "Unsupported in_format '#{val}'" unless f
38
45
  f
39
46
  end
40
47
  desc 'Specify comma-separated values for tsv format.'
41
- config_param :in_keys, :default => [] do |val|
48
+ config_param :in_keys, default: [] do |val|
42
49
  val.split(',')
43
50
  end
44
51
  desc 'The name of the key to use as the event tag.'
45
- config_param :in_tag_key, :default => nil
52
+ config_param :in_tag_key, default: nil
46
53
  desc 'The name of the key to use as the event time.'
47
- config_param :in_time_key, :default => nil
54
+ config_param :in_time_key, default: nil
48
55
  desc 'The format for event time used when the in_time_key parameter is specified.(Defauls is UNIX time)'
49
- config_param :in_time_format, :default => nil
56
+ config_param :in_time_format, default: nil
50
57
 
51
58
  desc "The format used to process the program output.(#{ExecUtil::SUPPORTED_FORMAT.keys.join(',')})"
52
- config_param :out_format, :default => :tsv do |val|
59
+ config_param :out_format, default: :tsv do |val|
53
60
  f = ExecUtil::SUPPORTED_FORMAT[val]
54
61
  raise ConfigError, "Unsupported out_format '#{val}'" unless f
55
62
  f
56
63
  end
57
64
  desc 'Specify comma-separated values for tsv format.'
58
- config_param :out_keys, :default => [] do |val| # for tsv format
65
+ config_param :out_keys, default: [] do |val| # for tsv format
59
66
  val.split(',')
60
67
  end
61
68
  desc 'The name of the key to use as the event tag.'
62
- config_param :out_tag_key, :default => nil
69
+ config_param :out_tag_key, default: nil
63
70
  desc 'The name of the key to use as the event time.'
64
- config_param :out_time_key, :default => nil
71
+ config_param :out_time_key, default: nil
65
72
  desc 'The format for event time used when the in_time_key parameter is specified.(Defauls is UNIX time)'
66
- config_param :out_time_format, :default => nil
73
+ config_param :out_time_format, default: nil
67
74
 
68
- config_param :tag, :string, :default => nil
75
+ config_param :tag, :string, default: nil
69
76
 
70
- config_param :time_key, :string, :default => nil
71
- config_param :time_format, :string, :default => nil
77
+ config_param :time_key, :string, default: nil
78
+ config_param :time_format, :string, default: nil
72
79
 
73
80
  desc 'If true, use localtime with in_time_format.'
74
- config_param :localtime, :bool, :default => true
81
+ config_param :localtime, :bool, default: true
75
82
  desc 'If true, use timezone with in_time_format.'
76
- config_param :timezone, :string, :default => nil
83
+ config_param :timezone, :string, default: nil
77
84
  desc 'The number of spawned process for command.'
78
- config_param :num_children, :integer, :default => 1
85
+ config_param :num_children, :integer, default: 1
79
86
 
80
87
  desc 'Respawn command when command exit.'
81
88
  # nil, 'none' or 0: no respawn, 'inf' or -1: infinite times, positive integer: try to respawn specified times only
82
- config_param :child_respawn, :string, :default => nil
89
+ config_param :child_respawn, :string, default: nil
83
90
 
84
91
  # 0: output logs for all of messages to emit
85
- config_param :suppress_error_log_interval, :time, :default => 0
92
+ config_param :suppress_error_log_interval, :time, default: 0
86
93
 
87
94
  config_set_default :flush_interval, 1
88
95
 
@@ -306,7 +313,7 @@ module Fluent
306
313
  chunk.write_to(@io)
307
314
  rescue Errno::EPIPE => e
308
315
  # Broken pipe (child process unexpectedly exited)
309
- @log.warn "exec_filter Broken pipe, child process maybe exited.", :command => @command
316
+ @log.warn "exec_filter Broken pipe, child process maybe exited.", command: @command
310
317
  if try_respawn
311
318
  retry # retry chunk#write_to with child respawned
312
319
  else
@@ -329,19 +336,19 @@ module Fluent
329
336
 
330
337
  @respawns -= 1 if @respawns > 0
331
338
  end
332
- @log.warn "exec_filter child process successfully respawned.", :command => @command, :respawns => @respawns
339
+ @log.warn "exec_filter child process successfully respawned.", command: @command, respawns: @respawns
333
340
  true
334
341
  end
335
342
 
336
343
  def run
337
344
  @parser.call(@io)
338
345
  rescue
339
- @log.error "exec_filter thread unexpectedly failed with an error.", :command=>@command, :error=>$!.to_s
346
+ @log.error "exec_filter thread unexpectedly failed with an error.", command: @command, error: $!.to_s
340
347
  @log.warn_backtrace $!.backtrace
341
348
  ensure
342
349
  pid, stat = Process.waitpid2(@pid)
343
350
  unless @finished
344
- @log.error "exec_filter process unexpectedly exited.", :command=>@command, :ecode=>stat.to_i
351
+ @log.error "exec_filter process unexpectedly exited.", command: @command, ecode: stat.to_i
345
352
  unless @respawns == 0
346
353
  @log.warn "exec_filter child process will respawn for next input data (respawns #{@respawns})."
347
354
  end
@@ -369,7 +376,7 @@ module Fluent
369
376
  router.emit(tag, time, record)
370
377
  rescue
371
378
  if @suppress_error_log_interval == 0 || Time.now.to_i > @next_log_time
372
- log.error "exec_filter failed to emit", :error=>$!.to_s, :error_class=>$!.class.to_s, :record=>Yajl.dump(record)
379
+ log.error "exec_filter failed to emit", error: $!.to_s, error_class: $!.class.to_s, record: Yajl.dump(record)
373
380
  log.warn_backtrace $!.backtrace
374
381
  @next_log_time = Time.now.to_i + @suppress_error_log_interval
375
382
  end
@@ -14,6 +14,12 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
+ require 'fileutils'
18
+ require 'zlib'
19
+
20
+ require 'fluent/output'
21
+ require 'fluent/config/error'
22
+
17
23
  module Fluent
18
24
  class FileOutput < TimeSlicedOutput
19
25
  Plugin.register_output('file', self)
@@ -26,11 +32,11 @@ module Fluent
26
32
  desc "The Path of the file."
27
33
  config_param :path, :string
28
34
  desc "The format of the file content. The default is out_file."
29
- config_param :format, :string, :default => 'out_file'
35
+ config_param :format, :string, default: 'out_file'
30
36
  desc "The flushed chunk is appended to existence file or not."
31
- config_param :append, :bool, :default => false
37
+ config_param :append, :bool, default: false
32
38
  desc "Compress flushed file."
33
- config_param :compress, :default => nil do |val|
39
+ config_param :compress, default: nil do |val|
34
40
  c = SUPPORTED_COMPRESS[val]
35
41
  unless c
36
42
  raise ConfigError, "Unsupported compression algorithm '#{val}'"
@@ -38,7 +44,7 @@ module Fluent
38
44
  c
39
45
  end
40
46
  desc "Create symlink to temporary buffered file when buffer_type is file."
41
- config_param :symlink_path, :string, :default => nil
47
+ config_param :symlink_path, :string, default: nil
42
48
 
43
49
  def initialize
44
50
  require 'zlib'
@@ -84,7 +90,7 @@ module Fluent
84
90
 
85
91
  def write(chunk)
86
92
  path = generate_path(chunk.key)
87
- FileUtils.mkdir_p File.dirname(path), :mode => DEFAULT_DIR_PERMISSION
93
+ FileUtils.mkdir_p File.dirname(path), mode: DEFAULT_DIR_PERMISSION
88
94
 
89
95
  case @compress
90
96
  when nil
@@ -14,6 +14,15 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
+ require 'base64'
18
+ require 'socket'
19
+ require 'fileutils'
20
+
21
+ require 'cool.io'
22
+
23
+ require 'fluent/output'
24
+ require 'fluent/config/error'
25
+
17
26
  module Fluent
18
27
  class ForwardOutputError < StandardError
19
28
  end
@@ -29,17 +38,14 @@ module Fluent
29
38
 
30
39
  def initialize
31
40
  super
32
- require "base64"
33
- require 'socket'
34
- require 'fileutils'
35
41
  require 'fluent/plugin/socket_util'
36
42
  @nodes = [] #=> [Node]
37
43
  end
38
44
 
39
45
  desc 'The timeout time when sending event logs.'
40
- config_param :send_timeout, :time, :default => 60
46
+ config_param :send_timeout, :time, default: 60
41
47
  desc 'The transport protocol to use for heartbeats.(udp,tcp,none)'
42
- config_param :heartbeat_type, :default => :udp do |val|
48
+ config_param :heartbeat_type, default: :udp do |val|
43
49
  case val.downcase
44
50
  when 'tcp'
45
51
  :tcp
@@ -52,34 +58,34 @@ module Fluent
52
58
  end
53
59
  end
54
60
  desc 'The interval of the heartbeat packer.'
55
- config_param :heartbeat_interval, :time, :default => 1
61
+ config_param :heartbeat_interval, :time, default: 1
56
62
  desc 'The wait time before accepting a server fault recovery.'
57
- config_param :recover_wait, :time, :default => 10
63
+ config_param :recover_wait, :time, default: 10
58
64
  desc 'The hard timeout used to detect server failure.'
59
- config_param :hard_timeout, :time, :default => 60
65
+ config_param :hard_timeout, :time, default: 60
60
66
  desc 'Set TTL to expire DNS cache in seconds.'
61
- config_param :expire_dns_cache, :time, :default => nil # 0 means disable cache
67
+ config_param :expire_dns_cache, :time, default: nil # 0 means disable cache
62
68
  desc 'The threshold parameter used to detect server faults.'
63
- config_param :phi_threshold, :integer, :default => 16
69
+ config_param :phi_threshold, :integer, default: 16
64
70
  desc 'Use the "Phi accrual failure detector" to detect server failure.'
65
- config_param :phi_failure_detector, :bool, :default => true
71
+ config_param :phi_failure_detector, :bool, default: true
66
72
 
67
73
  # if any options added that requires extended forward api, fix @extend_internal_protocol
68
74
 
69
75
  desc 'Change the protocol to at-least-once.'
70
- config_param :require_ack_response, :bool, :default => false # require in_forward to respond with ack
76
+ config_param :require_ack_response, :bool, default: false # require in_forward to respond with ack
71
77
  desc 'This option is used when require_ack_response is true.'
72
- config_param :ack_response_timeout, :time, :default => 190 # 0 means do not wait for ack responses
78
+ config_param :ack_response_timeout, :time, default: 190 # 0 means do not wait for ack responses
73
79
  # Linux default tcp_syn_retries is 5 (in many environment)
74
80
  # 3 + 6 + 12 + 24 + 48 + 96 -> 189 (sec)
75
81
  desc 'Enable client-side DNS round robin.'
76
- config_param :dns_round_robin, :bool, :default => false # heartbeat_type 'udp' is not available for this
82
+ config_param :dns_round_robin, :bool, default: false # heartbeat_type 'udp' is not available for this
77
83
 
78
84
  attr_reader :nodes
79
85
 
80
86
  # backward compatibility
81
- config_param :port, :integer, :default => DEFAULT_LISTEN_PORT
82
- config_param :host, :string, :default => nil
87
+ config_param :port, :integer, default: DEFAULT_LISTEN_PORT
88
+ config_param :host, :string, default: nil
83
89
 
84
90
  attr_accessor :extend_internal_protocol
85
91
 
@@ -138,7 +144,7 @@ module Fluent
138
144
  else
139
145
  @nodes << Node.new(log, node_conf)
140
146
  end
141
- log.info "adding forwarding server '#{name}'", :host=>host, :port=>port, :weight=>weight, :plugin_id=>plugin_id
147
+ log.info "adding forwarding server '#{name}'", host: host, port: port, weight: weight, plugin_id: plugin_id
142
148
  }
143
149
 
144
150
  if @nodes.empty?
@@ -184,7 +190,7 @@ module Fluent
184
190
  def run
185
191
  @loop.run if @loop
186
192
  rescue
187
- log.error "unexpected error", :error=>$!.to_s
193
+ log.error "unexpected error", error: $!.to_s
188
194
  log.error_backtrace
189
195
  end
190
196
 
@@ -229,13 +235,13 @@ module Fluent
229
235
  lost_weight += n.weight
230
236
  end
231
237
  }
232
- log.debug "rebuilding weight array", :lost_weight=>lost_weight
238
+ log.debug "rebuilding weight array", lost_weight: lost_weight
233
239
 
234
240
  if lost_weight > 0
235
241
  standby_nodes.each {|n|
236
242
  if n.available?
237
243
  regular_nodes << n
238
- log.warn "using standby node #{n.host}:#{n.port}", :weight=>n.weight
244
+ log.warn "using standby node #{n.host}:#{n.port}", weight: n.weight
239
245
  lost_weight -= n.weight
240
246
  break if lost_weight <= 0
241
247
  end
@@ -399,7 +405,7 @@ module Fluent
399
405
  end
400
406
  rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::EINTR, Errno::ECONNREFUSED
401
407
  # TODO log
402
- log.debug "failed to send heartbeat packet to #{n.host}:#{n.port}", :error=>$!.to_s
408
+ log.debug "failed to send heartbeat packet to #{n.host}:#{n.port}", error: $!.to_s
403
409
  end
404
410
  }
405
411
  end
@@ -511,7 +517,7 @@ module Fluent
511
517
  end
512
518
 
513
519
  if @failure.hard_timeout?(now)
514
- @log.warn "detached forwarding server '#{@name}'", :host=>@host, :port=>@port, :hard_timeout=>true
520
+ @log.warn "detached forwarding server '#{@name}'", host: @host, port: @port, hard_timeout: true
515
521
  @available = false
516
522
  @resolved_host = nil # expire cached host
517
523
  @failure.clear
@@ -522,7 +528,7 @@ module Fluent
522
528
  phi = @failure.phi(now)
523
529
  #$log.trace "phi '#{@name}'", :host=>@host, :port=>@port, :phi=>phi
524
530
  if phi > @conf.phi_threshold
525
- @log.warn "detached forwarding server '#{@name}'", :host=>@host, :port=>@port, :phi=>phi
531
+ @log.warn "detached forwarding server '#{@name}'", host: @host, port: @port, phi: phi
526
532
  @available = false
527
533
  @resolved_host = nil # expire cached host
528
534
  @failure.clear
@@ -538,7 +544,7 @@ module Fluent
538
544
  #@log.trace "heartbeat from '#{@name}'", :host=>@host, :port=>@port, :available=>@available, :sample_size=>@failure.sample_size
539
545
  if detect && !@available && @failure.sample_size > @conf.recover_sample_size
540
546
  @available = true
541
- @log.warn "recovered forwarding server '#{@name}'", :host=>@host, :port=>@port
547
+ @log.warn "recovered forwarding server '#{@name}'", host: @host, port: @port
542
548
  return true
543
549
  else
544
550
  return nil
@@ -14,6 +14,8 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
+ require 'fluent/output'
18
+
17
19
  module Fluent
18
20
  class NullOutput < Output
19
21
  Plugin.register_output('null', self)
@@ -14,6 +14,8 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
+ require 'fluent/output'
18
+
17
19
  module Fluent
18
20
  class RelabelOutput < Output
19
21
  Plugin.register_output('relabel', self)
@@ -14,6 +14,9 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
+ require 'fluent/output'
18
+ require 'fluent/config/error'
19
+
17
20
  module Fluent
18
21
  class RoundRobinOutput < MultiOutput
19
22
  Plugin.register_output('roundrobin', self)
@@ -14,12 +14,14 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
+ require 'fluent/output'
18
+
17
19
  module Fluent
18
20
  class StdoutOutput < Output
19
21
  Plugin.register_output('stdout', self)
20
22
 
21
23
  desc 'Output format.(json,hash)'
22
- config_param :output_type, :default => 'json'
24
+ config_param :output_type, default: 'json'
23
25
 
24
26
  def configure(conf)
25
27
  super
@@ -14,16 +14,16 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
+ require 'socket'
18
+ require 'fileutils'
19
+
20
+ require 'fluent/output'
21
+ require 'fluent/event'
22
+
17
23
  module Fluent
18
24
  # obsolete
19
25
  class StreamOutput < BufferedOutput
20
- def initialize
21
- require 'socket'
22
- require 'fileutils'
23
- super
24
- end
25
-
26
- config_param :send_timeout, :time, :default => 60
26
+ config_param :send_timeout, :time, default: 60
27
27
 
28
28
  def configure(conf)
29
29
  super
@@ -91,7 +91,7 @@ module Fluent
91
91
  $log.warn "see 'forward' section in http://docs.fluentd.org/ for the high-availability configuration."
92
92
  end
93
93
 
94
- config_param :port, :integer, :default => DEFAULT_LISTEN_PORT
94
+ config_param :port, :integer, default: DEFAULT_LISTEN_PORT
95
95
  config_param :host, :string
96
96
 
97
97
  def configure(conf)
@@ -14,13 +14,15 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
+ require 'ipaddr'
18
+
17
19
  require 'cool.io'
18
20
 
21
+ require 'fluent/plugin'
22
+
19
23
  module Fluent
20
24
  module SocketUtil
21
25
  def create_udp_socket(host)
22
- require 'ipaddr'
23
-
24
26
  if IPAddr.new(IPSocket.getaddress(host)).ipv4?
25
27
  UDPSocket.new
26
28
  else
@@ -43,7 +45,7 @@ module Fluent
43
45
  msg.chomp!
44
46
  @callback.call(msg, addr)
45
47
  rescue => e
46
- @log.error "unexpected error", :error => e, :error_class => e.class
48
+ @log.error "unexpected error", error: e, error_class: e.class
47
49
  end
48
50
  end
49
51
 
@@ -79,7 +81,7 @@ module Fluent
79
81
  end
80
82
  @buffer.slice!(0, pos) if pos > 0
81
83
  rescue => e
82
- @log.error "unexpected error", :error => e, :error_class => e.class
84
+ @log.error "unexpected error", error: e, error_class: e.class
83
85
  close
84
86
  end
85
87
 
@@ -99,12 +101,12 @@ module Fluent
99
101
  desc 'The format of the payload.'
100
102
  config_param :format, :string
101
103
  desc 'The port to listen to.'
102
- config_param :port, :integer, :default => 5150
104
+ config_param :port, :integer, default: 5150
103
105
  desc 'The bind address to listen to.'
104
- config_param :bind, :string, :default => '0.0.0.0'
106
+ config_param :bind, :string, default: '0.0.0.0'
105
107
  desc "The field name of the client's hostname."
106
- config_param :source_host_key, :string, :default => nil
107
- config_param :blocking_timeout, :time, :default => 0.5
108
+ config_param :source_host_key, :string, default: nil
109
+ config_param :blocking_timeout, :time, default: 0.5
108
110
 
109
111
  def configure(conf)
110
112
  super
@@ -130,7 +132,7 @@ module Fluent
130
132
  def run
131
133
  @loop.run(@blocking_timeout)
132
134
  rescue => e
133
- log.error "unexpected error", :error => e, :error_class => e.class
135
+ log.error "unexpected error", error: e, error_class: e.class
134
136
  log.error_backtrace
135
137
  end
136
138
 
@@ -147,7 +149,7 @@ module Fluent
147
149
  router.emit(@tag, time, record)
148
150
  }
149
151
  rescue => e
150
- log.error msg.dump, :error => e, :error_class => e.class, :host => addr[3]
152
+ log.error msg.dump, error: e, error_class: e.class, host: addr[3]
151
153
  log.error_backtrace
152
154
  end
153
155
  end