fluentd 1.9.3-x64-mingw32 → 1.10.0-x64-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.

Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/issue-auto-closer.yml +12 -0
  3. data/CHANGELOG.md +48 -0
  4. data/lib/fluent/msgpack_factory.rb +13 -6
  5. data/lib/fluent/plugin/buffer.rb +2 -2
  6. data/lib/fluent/plugin/in_dummy.rb +1 -1
  7. data/lib/fluent/plugin/in_tail.rb +35 -26
  8. data/lib/fluent/plugin/out_forward.rb +4 -6
  9. data/lib/fluent/plugin/out_forward/handshake_protocol.rb +4 -0
  10. data/lib/fluent/plugin/parser_syslog.rb +114 -34
  11. data/lib/fluent/plugin/sd_file.rb +1 -0
  12. data/lib/fluent/plugin/sd_srv.rb +135 -0
  13. data/lib/fluent/plugin_helper/cert_option.rb +15 -2
  14. data/lib/fluent/plugin_helper/server.rb +3 -1
  15. data/lib/fluent/plugin_helper/socket_option.rb +19 -1
  16. data/lib/fluent/version.rb +1 -1
  17. data/test/command/test_fluentd.rb +14 -2
  18. data/test/helper.rb +2 -2
  19. data/test/plugin/in_tail/test_fifo.rb +121 -0
  20. data/test/plugin/in_tail/test_io_handler.rb +132 -0
  21. data/test/plugin/in_tail/test_position_file.rb +1 -1
  22. data/test/plugin/out_forward/test_handshake_protocol.rb +10 -1
  23. data/test/plugin/test_buf_file.rb +3 -1
  24. data/test/plugin/test_buffer.rb +20 -0
  25. data/test/plugin/test_compressable.rb +7 -4
  26. data/test/plugin/test_in_dummy.rb +12 -14
  27. data/test/plugin/test_in_forward.rb +2 -2
  28. data/test/plugin/test_in_tail.rb +6 -6
  29. data/test/plugin/test_out_forward.rb +28 -1
  30. data/test/plugin/test_output_as_buffered_secondary.rb +1 -1
  31. data/test/plugin/test_parser_syslog.rb +46 -34
  32. data/test/plugin/test_sd_file.rb +17 -0
  33. data/test/plugin/test_sd_srv.rb +230 -0
  34. data/test/plugin_helper/data/cert/cert-with-CRLF.pem +19 -0
  35. data/test/plugin_helper/test_cert_option.rb +2 -0
  36. data/test/plugin_helper/test_child_process.rb +5 -3
  37. data/test/test_msgpack_factory.rb +18 -0
  38. metadata +14 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8350e64a62d8fb35540a14a24fce3ae04873c92c13eaae557e8038f57ea6350
4
- data.tar.gz: 8040f800374683a299abafe6b8c5fa0f4d45d9c9612625a177b2122a3a7343a6
3
+ metadata.gz: c46e09e3c3d3d1efdff6c3e170ac84b1cca7a0dea88eec6bb58da9f9f1efc8e9
4
+ data.tar.gz: 5f2338a9cbd7e144392ce131c80cdf7b0176d9fb30912fe903731a7352b00c85
5
5
  SHA512:
6
- metadata.gz: dc6be2a746153c6e5a2e97a2e2e3b616056cece4ec4dd80fc52f185c44e29214ef7da7a2e4dfb43b3c11edc60d2dc5947a606a56fc0067694ed6196da0bf2391
7
- data.tar.gz: e3810d24015a37ffd983be9ca9810ce2b3f2aaaa4557592a9a5e3ef179e288e98f7e08abdb17e64391e792bd54bb59e721201dbe6c769428a31961d08294d618
6
+ metadata.gz: 39af8cd1e1d4c4034c2e5716f6f9d3bfbcd59a79f33bcc8d7e595357b63582f45a68d8055faec82dd28cec025f97f42ce559487ea0765580ae1b5e69a20163af
7
+ data.tar.gz: 2d730fb947eb5f1287856c2db20c9cb43fa997dd564eb677f7f440780f293eea2f1e0ff073169d8d2c923ff3c6bf9340e934eb8ba773fad38da27c364eab8054
@@ -0,0 +1,12 @@
1
+ name: Autocloser
2
+ on: [issues]
3
+ jobs:
4
+ autoclose:
5
+ runs-on: ubuntu-latest
6
+ steps:
7
+ - name: Autoclose issues that did not follow issue template
8
+ uses: roots/issue-closer-action@v1.1
9
+ with:
10
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
11
+ issue-close-message: "@${issue.user.login} this issue was automatically closed because it did not follow the issue template"
12
+ issue-pattern: "(.*Describe the bug.*)|(.*Is your feature request related to a problem.*)"
@@ -1,3 +1,51 @@
1
+ # v1.10
2
+
3
+ ## Release v1.10.0 - 2020/03/24
4
+
5
+ ### New feature
6
+
7
+ * sd plugin: Add RSV record plugin
8
+ https://github.com/fluent/fluentd/pull/2876
9
+
10
+ ### Enhancement
11
+
12
+ * server: Add `cert_verifier` parameter for TLS transport
13
+ https://github.com/fluent/fluentd/pull/2888
14
+ * parser_syslog: Support customized time format
15
+ https://github.com/fluent/fluentd/pull/2886
16
+ * in_dummy: Delete `suspend` parameter
17
+ https://github.com/fluent/fluentd/pull/2897
18
+ * Refactor code
19
+ https://github.com/fluent/fluentd/pull/2858
20
+ https://github.com/fluent/fluentd/pull/2862
21
+ https://github.com/fluent/fluentd/pull/2864
22
+ https://github.com/fluent/fluentd/pull/2869
23
+ https://github.com/fluent/fluentd/pull/2870
24
+ https://github.com/fluent/fluentd/pull/2874
25
+ https://github.com/fluent/fluentd/pull/2881
26
+ https://github.com/fluent/fluentd/pull/2885
27
+ https://github.com/fluent/fluentd/pull/2894
28
+ https://github.com/fluent/fluentd/pull/2896
29
+ https://github.com/fluent/fluentd/pull/2898
30
+ https://github.com/fluent/fluentd/pull/2899
31
+ https://github.com/fluent/fluentd/pull/2900
32
+ https://github.com/fluent/fluentd/pull/2901
33
+ https://github.com/fluent/fluentd/pull/2906
34
+
35
+ ### Bug fix
36
+
37
+ * out_forward: windows: Permit to specify `linger_timeout`
38
+ https://github.com/fluent/fluentd/pull/2868
39
+ * parser_syslog: Fix syslog format detection
40
+ https://github.com/fluent/fluentd/pull/2879
41
+ * buffer: Fix `available_buffer_space_ratio` calculation
42
+ https://github.com/fluent/fluentd/pull/2882
43
+ * tls: Support CRLF based X.509 certificates
44
+ https://github.com/fluent/fluentd/pull/2890
45
+ * msgpack_factory mixin: Fix performance penalty for deprecation log
46
+ https://github.com/fluent/fluentd/pull/2903
47
+
48
+
1
49
  # v1.9
2
50
 
3
51
  ## Release v1.9.3 - 2020/03/05
@@ -23,25 +23,32 @@ module Fluent
23
23
 
24
24
  module Mixin
25
25
  def msgpack_factory
26
- if $log
27
- $log.warn('Deprecated method: this method is going to be deleted. Use Fluent::MessagePackFactory.engine_factory')
26
+ unless @deprecated_log_done
27
+ deprecated_log('Deprecated method: this method is going to be deleted. Use Fluent::MessagePackFactory.engine_factory')
28
28
  end
29
29
  MessagePackFactory.engine_factory
30
30
  end
31
31
 
32
32
  def msgpack_packer(*args)
33
- if $log
34
- $log.warn('Deprecated method: this method is going to be deleted. Use Fluent::MessagePackFactory.msgpack_packer')
33
+ unless @deprecated_log_done
34
+ deprecated_log('Deprecated method: this method is going to be deleted. Use Fluent::MessagePackFactory.msgpack_packer')
35
35
  end
36
36
  MessagePackFactory.msgpack_packer(*args)
37
37
  end
38
38
 
39
39
  def msgpack_unpacker(*args)
40
- if $log
41
- $log.warn('Deprecated method: this method is going to be deleted. Use Fluent::MessagePackFactory.msgpack_unpacker')
40
+ unless @deprecated_log_done
41
+ deprecated_log('Deprecated method: this method is going to be deleted. Use Fluent::MessagePackFactory.msgpack_unpacker')
42
42
  end
43
43
  MessagePackFactory.msgpack_unpacker(*args)
44
44
  end
45
+
46
+ def deprecated_log(str)
47
+ if $log
48
+ $log.warn(str)
49
+ @deprecated_log_done = true
50
+ end
51
+ end
45
52
  end
46
53
 
47
54
  def self.engine_factory(enable_time_support: false)
@@ -758,13 +758,13 @@ module Fluent
758
758
 
759
759
  def statistics
760
760
  stage_size, queue_size = @stage_size, @queue_size
761
- buffer_space = 1.0 - ((stage_size + queue_size * 1.0) / @total_limit_size).round
761
+ buffer_space = 1.0 - ((stage_size + queue_size * 1.0) / @total_limit_size)
762
762
  stats = {
763
763
  'stage_length' => @stage.size,
764
764
  'stage_byte_size' => stage_size,
765
765
  'queue_length' => @queue.size,
766
766
  'queue_byte_size' => queue_size,
767
- 'available_buffer_space_ratios' => buffer_space * 100,
767
+ 'available_buffer_space_ratios' => (buffer_space * 100).round(1),
768
768
  'total_queued_size' => stage_size + queue_size,
769
769
  }
770
770
 
@@ -37,7 +37,7 @@ module Fluent::Plugin
37
37
  desc "If specified, each generated event has an auto-incremented key field."
38
38
  config_param :auto_increment_key, :string, default: nil
39
39
  desc "The boolean to suspend-and-resume incremental value after restart"
40
- config_param :suspend, :bool, default: false
40
+ config_param :suspend, :bool, default: false,deprecated: 'This parameters is ignored'
41
41
  desc "The dummy data to be generated. An array of JSON hashes or a single JSON hash."
42
42
  config_param :dummy, default: [{"message"=>"dummy"}] do |val|
43
43
  begin
@@ -319,7 +319,7 @@ module Fluent::Plugin
319
319
 
320
320
  def setup_watcher(path, pe)
321
321
  line_buffer_timer_flusher = @multiline_mode ? TailWatcher::LineBufferTimerFlusher.new(log, @multiline_flush_interval, &method(:flush_buffer)) : nil
322
- tw = TailWatcher.new(path, pe, log, @read_from_head, @read_lines_limit, method(:update_watcher), line_buffer_timer_flusher, @from_encoding, @encoding, open_on_every_update, &method(:receive_lines))
322
+ tw = TailWatcher.new(path, pe, log, @read_from_head, method(:update_watcher), line_buffer_timer_flusher, method(:io_handler))
323
323
 
324
324
  if @enable_watch_timer
325
325
  tt = TimerTrigger.new(1, log) { tw.on_notify }
@@ -555,6 +555,21 @@ module Fluent::Plugin
555
555
  es
556
556
  end
557
557
 
558
+ private
559
+
560
+ def io_handler(watcher, path)
561
+ TailWatcher::IOHandler.new(
562
+ watcher,
563
+ path: path,
564
+ log: log,
565
+ read_lines_limit: @read_lines_limit,
566
+ open_on_every_update: @open_on_every_update,
567
+ from_encoding: @from_encoding,
568
+ encoding: @encoding,
569
+ &method(:receive_lines)
570
+ )
571
+ end
572
+
558
573
  class StatWatcher < Coolio::StatWatcher
559
574
  def initialize(path, log, &callback)
560
575
  @callback = callback
@@ -586,22 +601,16 @@ module Fluent::Plugin
586
601
  end
587
602
 
588
603
  class TailWatcher
589
- def initialize(path, pe, log, read_from_head, read_lines_limit, update_watcher, line_buffer_timer_flusher, from_encoding, encoding, open_on_every_update, &receive_lines)
604
+ def initialize(path, pe, log, read_from_head, update_watcher, line_buffer_timer_flusher, io_handler_build)
590
605
  @path = path
591
606
  @pe = pe || MemoryPositionEntry.new
592
607
  @read_from_head = read_from_head
593
- @read_lines_limit = read_lines_limit
594
- @receive_lines = receive_lines
595
608
  @update_watcher = update_watcher
596
-
597
- @rotate_handler = RotateHandler.new(log, &method(:on_rotate))
598
- @io_handler = nil
599
609
  @log = log
600
-
610
+ @rotate_handler = RotateHandler.new(log, &method(:on_rotate))
601
611
  @line_buffer_timer_flusher = line_buffer_timer_flusher
602
- @from_encoding = from_encoding
603
- @encoding = encoding
604
- @open_on_every_update = open_on_every_update
612
+ @io_handler = nil
613
+ @io_handler_build = io_handler_build
605
614
  @watchers = []
606
615
  end
607
616
 
@@ -709,9 +718,7 @@ module Fluent::Plugin
709
718
  end
710
719
 
711
720
  def io_handler
712
- IOHandler.new(self, path: @path, log: @log, read_lines_limit: @read_lines_limit, open_on_every_update: @open_on_every_update, from_encoding: @from_encoding, encoding: @encoding) do |lines|
713
- @receive_lines.call(lines, self)
714
- end
721
+ @io_handler_build.call(self, @path)
715
722
  end
716
723
 
717
724
  def swap_state(pe)
@@ -801,6 +808,19 @@ module Fluent::Plugin
801
808
  @notify_mutex.synchronize { handle_notify }
802
809
  end
803
810
 
811
+ def close
812
+ if @io && !@io.closed?
813
+ @io.close
814
+ @io = nil
815
+ end
816
+ end
817
+
818
+ def opened?
819
+ !!@io
820
+ end
821
+
822
+ private
823
+
804
824
  def handle_notify
805
825
  with_io do |io|
806
826
  begin
@@ -822,7 +842,7 @@ module Fluent::Plugin
822
842
  end
823
843
 
824
844
  unless @lines.empty?
825
- if @receive_lines.call(@lines)
845
+ if @receive_lines.call(@lines, @watcher)
826
846
  @watcher.pe.update_pos(io.pos - @fifo.bytesize)
827
847
  @lines.clear
828
848
  else
@@ -833,17 +853,6 @@ module Fluent::Plugin
833
853
  end
834
854
  end
835
855
 
836
- def close
837
- if @io && !@io.closed?
838
- @io.close
839
- @io = nil
840
- end
841
- end
842
-
843
- def opened?
844
- !!@io
845
- end
846
-
847
856
  def open
848
857
  io = Fluent::FileWrapper.open(@path)
849
858
  io.seek(@watcher.pe.read_pos + @fifo.bytesize)
@@ -382,9 +382,7 @@ module Fluent::Plugin
382
382
  cert_logical_store_name: @tls_cert_logical_store_name,
383
383
  cert_use_enterprise_store: @tls_cert_use_enterprise_store,
384
384
 
385
- # Enabling SO_LINGER causes data loss on Windows
386
- # https://github.com/fluent/fluentd/issues/1968
387
- linger_timeout: Fluent.windows? ? nil : @send_timeout,
385
+ linger_timeout: @send_timeout,
388
386
  send_timeout: @send_timeout,
389
387
  recv_timeout: @ack_response_timeout,
390
388
  connect_timeout: @connect_timeout,
@@ -510,7 +508,7 @@ module Fluent::Plugin
510
508
 
511
509
  class Node
512
510
  extend Forwardable
513
- def_delegators :@server, :discovery_id, :host, :port, :name, :weight, :standby, :username, :password, :shared_key
511
+ def_delegators :@server, :discovery_id, :host, :port, :name, :weight, :standby
514
512
 
515
513
  # @param connection_manager [Fluent::Plugin::ForwardOutput::ConnectionManager]
516
514
  # @param ack_handler [Fluent::Plugin::ForwardOutput::AckHandler]
@@ -542,8 +540,8 @@ module Fluent::Plugin
542
540
  log: @log,
543
541
  hostname: sender.security && sender.security.self_hostname,
544
542
  shared_key: server.shared_key || (sender.security && sender.security.shared_key) || '',
545
- password: server.password,
546
- username: server.username,
543
+ password: server.password || '',
544
+ username: server.username || '',
547
545
  )
548
546
 
549
547
  @unpacker = Fluent::MessagePackFactory.msgpack_unpacker
@@ -105,6 +105,10 @@ module Fluent::Plugin
105
105
  .hexdigest
106
106
  ping = ['PING', @hostname, @shared_key_salt, shared_key_hexdigest]
107
107
  if !ri.auth.empty?
108
+ if @username.nil? || @password.nil?
109
+ raise PingpongError, "username and password are required"
110
+ end
111
+
108
112
  password_hexdigest = Digest::SHA512.new.update(ri.auth).update(@username).update(@password).hexdigest
109
113
  ping.push(@username, password_hexdigest)
110
114
  else
@@ -23,6 +23,7 @@ module Fluent
23
23
  class SyslogParser < Parser
24
24
  Plugin.register_parser('syslog', self)
25
25
 
26
+ # TODO: Remove them since these regexps are no longer needed. but keep them for compatibility for now
26
27
  # From existence TextParser pattern
27
28
  REGEXP = /^(?<time>[^ ]*\s*[^ ]* [^ ]*) (?<host>[^ ]*) (?<ident>[^ :\[]*)(?:\[(?<pid>[0-9]+)\])?(?:[^\:]*\:)? *(?<message>.*)$/
28
29
  # From in_syslog default pattern
@@ -36,7 +37,16 @@ module Fluent
36
37
  REGEXP_RFC5424_WITH_PRI = Regexp.new(<<~'EOS'.chomp % REGEXP_RFC5424, Regexp::MULTILINE)
37
38
  \A<(?<pri>[0-9]{1,3})\>[1-9]\d{0,2} %s\z
38
39
  EOS
39
- REGEXP_DETECT_RFC5424 = /^\<.*\>[1-9]\d{0,2}/
40
+
41
+ REGEXP_DETECT_RFC5424 = /^\<[0-9]{1,3}\>[1-9]\d{0,2}/
42
+
43
+ RFC3164_WITHOUT_TIME_AND_PRI_REGEXP = /(?<host>[^ ]*) (?<ident>[^ :\[]*)(?:\[(?<pid>[0-9]+)\])?(?:[^\:]*\:)? *(?<message>.*)$/
44
+ RFC3164_CAPTURES = RFC3164_WITHOUT_TIME_AND_PRI_REGEXP.names.freeze
45
+ RFC3164_PRI_REGEXP = /^<(?<pri>[0-9]{1,3})>/
46
+
47
+ RFC5424_WITHOUT_TIME_AND_PRI_REGEXP = /(?<host>[!-~]{1,255}) (?<ident>[!-~]{1,48}) (?<pid>[!-~]{1,128}) (?<msgid>[!-~]{1,32}) (?<extradata>(?:\-|(?:\[.*?(?<!\\)\])+))(?: (?<message>.+))?\z/m
48
+ RFC5424_CAPTURES = RFC5424_WITHOUT_TIME_AND_PRI_REGEXP.names.freeze
49
+ RFC5424_PRI_REGEXP = /^<(?<pri>\d{1,3})>\d\d{0,2}\s/
40
50
 
41
51
  config_set_default :time_format, "%b %d %H:%M:%S"
42
52
  desc 'If the incoming logs have priority prefix, e.g. <9>, set true'
@@ -53,6 +63,8 @@ module Fluent
53
63
  def initialize
54
64
  super
55
65
  @mutex = Mutex.new
66
+ @space_count = nil
67
+ @space_count_rfc5424 = nil
56
68
  end
57
69
 
58
70
  def configure(conf)
@@ -66,21 +78,21 @@ module Fluent
66
78
  when :rfc3164
67
79
  if @regexp_parser
68
80
  class << self
69
- alias_method :parse, :parse_plain
81
+ alias_method :parse, :parse_rfc3164_regex
70
82
  end
71
83
  else
72
84
  class << self
73
85
  alias_method :parse, :parse_rfc3164
74
86
  end
75
87
  end
76
- @with_priority ? REGEXP_WITH_PRI : REGEXP
88
+ RFC3164_WITHOUT_TIME_AND_PRI_REGEXP
77
89
  when :rfc5424
78
90
  class << self
79
- alias_method :parse, :parse_plain
91
+ alias_method :parse, :parse_rfc5424_regex
80
92
  end
81
93
  @time_format = @rfc5424_time_format unless conf.has_key?('time_format')
82
94
  @support_rfc5424_without_subseconds = true
83
- @with_priority ? REGEXP_RFC5424_WITH_PRI : REGEXP_RFC5424_NO_PRI
95
+ RFC5424_WITHOUT_TIME_AND_PRI_REGEXP
84
96
  when :auto
85
97
  class << self
86
98
  alias_method :parse, :parse_auto
@@ -89,10 +101,14 @@ module Fluent
89
101
  @time_parser_rfc5424 = time_parser_create(format: @rfc5424_time_format)
90
102
  nil
91
103
  end
104
+
105
+ @space_count = @time_format.squeeze(' ').count(' ') + 1
106
+ @space_count_rfc5424 = @rfc5424_time_format.squeeze(' ').count(' ') + 1
92
107
  @time_parser = time_parser_create
93
108
  @time_parser_rfc5424_without_subseconds = time_parser_create(format: "%Y-%m-%dT%H:%M:%S%z")
94
109
  end
95
110
 
111
+ # this method is for tests
96
112
  def patterns
97
113
  {'format' => @regexp, 'time_format' => @time_format}
98
114
  end
@@ -103,51 +119,115 @@ module Fluent
103
119
 
104
120
  def parse_auto(text, &block)
105
121
  if REGEXP_DETECT_RFC5424.match(text)
106
- @regexp = @with_priority ? REGEXP_RFC5424_WITH_PRI : REGEXP_RFC5424_NO_PRI
122
+ @regexp = RFC5424_WITHOUT_TIME_AND_PRI_REGEXP
107
123
  @time_parser = @time_parser_rfc5424
108
124
  @support_rfc5424_without_subseconds = true
109
- parse_plain(text, &block)
125
+ parse_rfc5424_regex(text, &block)
110
126
  else
111
- @regexp = @with_priority ? REGEXP_WITH_PRI : REGEXP
127
+ @regexp = RFC3164_WITHOUT_TIME_AND_PRI_REGEXP
112
128
  @time_parser = @time_parser_rfc3164
113
129
  if @regexp_parser
114
- parse_plain(text, &block)
130
+ parse_rfc3164_regex(text, &block)
115
131
  else
116
132
  parse_rfc3164(text, &block)
117
133
  end
118
134
  end
119
135
  end
120
136
 
121
- def parse_plain(text, &block)
122
- m = @regexp.match(text)
123
- unless m
124
- yield nil, nil
125
- return
137
+ def parse_rfc3164_regex(text, &block)
138
+ idx = 0
139
+ record = {}
140
+
141
+ if @with_priority
142
+ if RFC3164_PRI_REGEXP.match?(text)
143
+ v = text.index('>')
144
+ record['pri'] = text[1..v].to_i # trim `<` and ``>
145
+ idx = v + 1
146
+ else
147
+ yield(nil, nil)
148
+ return
149
+ end
126
150
  end
127
151
 
128
- time = nil
152
+ i = idx - 1
153
+ sq = false
154
+ @space_count.times do
155
+ while text[i + 1] == ' '.freeze
156
+ sq = true
157
+ i += 1
158
+ end
159
+
160
+ i = text.index(' '.freeze, i + 1)
161
+ end
162
+
163
+ time_str = sq ? text.slice(idx, i - idx).squeeze(' ') : text.slice(idx, i - idx)
164
+ time = @mutex.synchronize { @time_parser.parse(time_str) }
165
+ if @keep_time_key
166
+ record['time'] = time_str
167
+ end
168
+
169
+ parse_plain(time, text, i + 1, record, RFC3164_CAPTURES, &block)
170
+ end
171
+
172
+ def parse_rfc5424_regex(text, &block)
173
+ idx = 0
129
174
  record = {}
130
175
 
131
- m.names.each { |name|
132
- if value = m[name]
176
+ if @with_priority
177
+ if (m = RFC5424_PRI_REGEXP.match(text))
178
+ record['pri'] = m['pri']
179
+ idx = m.end(0)
180
+ else
181
+ yield(nil, nil)
182
+ return
183
+ end
184
+ end
185
+
186
+ i = idx - 1
187
+ sq = false
188
+ @space_count_rfc5424.times {
189
+ while text[i + 1] == ' '.freeze
190
+ sq = true
191
+ i += 1
192
+ end
193
+
194
+ i = text.index(' '.freeze, i + 1)
195
+ }
196
+
197
+ time_str = sq ? text.slice(idx, i - idx).squeeze(' '.freeze) : text.slice(idx, i - idx)
198
+ time = @mutex.synchronize do
199
+ begin
200
+ @time_parser.parse(time_str)
201
+ rescue Fluent::TimeParser::TimeParseError => e
202
+ if @support_rfc5424_without_subseconds
203
+ log.trace(e)
204
+ @time_parser_rfc5424_without_subseconds.parse(time_str)
205
+ else
206
+ raise
207
+ end
208
+ end
209
+ end
210
+
211
+ if @keep_time_key
212
+ record['time'] = time_str
213
+ end
214
+ parse_plain(time, text, i + 1, record, RFC5424_CAPTURES, &block)
215
+ end
216
+
217
+ # @param time [EventTime]
218
+ # @param idx [Integer] note: this argument is needed to avoid string creation
219
+ # @param record [Hash]
220
+ # @param capture_list [Array] for performance
221
+ def parse_plain(time, text, idx, record, capture_list, &block)
222
+ m = @regexp.match(text, idx)
223
+ if m.nil?
224
+ yield nil, nil
225
+ return
226
+ end
227
+
228
+ capture_list.each { |name|
229
+ if value = (m[name] rescue nil)
133
230
  case name
134
- when "pri"
135
- record['pri'] = value.to_i
136
- when "time"
137
- time = @mutex.synchronize do
138
- time_str = value.squeeze(' ')
139
- begin
140
- @time_parser.parse(time_str)
141
- rescue Fluent::TimeParser::TimeParseError => e
142
- if @support_rfc5424_without_subseconds
143
- log.trace(e)
144
- @time_parser_rfc5424_without_subseconds.parse(time_str)
145
- else
146
- raise
147
- end
148
- end
149
- end
150
- record[name] = value if @keep_time_key
151
231
  when "message"
152
232
  value.chomp!
153
233
  record[name] = value