Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/fluent/plugin/parser_syslog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def parse_rfc5424(text, &block)
i = text.index(SPLIT_CHAR, i + 1)
end

time_str = sq ? text.slice(idx, i - cursor).squeeze(SPLIT_CHAR) : text.slice(cursor, i - cursor)
time_str = sq ? text.slice(cursor, i - cursor).squeeze(SPLIT_CHAR) : text.slice(cursor, i - cursor)
cursor = i + 1
end

Expand Down
22 changes: 22 additions & 0 deletions test/plugin/test_parser_syslog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,28 @@ def test_parse_does_not_accept_space_after_rfc5424_priority(data)
assert_input_rejected(text, expectation)
end

def test_parse_rfc5424_with_space_containing_time_format
@parser.configure(
'parser_engine' => 'string',
'message_format' => 'rfc5424',
'with_priority' => true,
'time_format' => '%b %d %H:%M:%S',
)

result = nil
@parser.instance.parse('<16>1 Feb 6 13:14:15 192.168.0.1 fluentd 11111 ID - Hi, from Fluentd!') do |time, record|
result = [time, record]
end

time, record = result
assert_equal(event_time('Feb 6 13:14:15', format: '%b %d %H:%M:%S'), time)
assert_equal(
{'host' => '192.168.0.1', 'ident' => 'fluentd', 'pid' => '11111', 'msgid' => 'ID',
'pri' => 16, 'extradata' => '-', 'message' => 'Hi, from Fluentd!'},
record,
)
end

data('regexp' => 'regexp', 'string' => 'string')
def test_parse_rfc5452_with_priority(param)
@parser.configure('with_priority' => true, 'parser_type' => param, 'message_format' => 'rfc5424')
Expand Down
Loading