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 @@ -314,7 +314,7 @@ def parse_rfc3164(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
17 changes: 17 additions & 0 deletions test/plugin/test_parser_syslog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,23 @@ def test_parse_with_priority(param)
assert_equal("%b %d %H:%M:%S", @parser.instance.patterns['time_format'])
end

def test_parse_with_space_padded_rfc3164_timestamp
@parser.configure(
'parser_engine' => 'string',
'with_priority' => true,
'time_format' => '%Y-%m-%d %H:%M:%S',
)

result = nil
@parser.instance.parse('<6>2020-02-28 12:00:00 192.168.0.1 fluentd[11111]: [error] Syslog test') do |time, record|
result = [time, record]
end

time, record = result
assert_equal(event_time('2020-02-28 12:00:00', format: '%Y-%m-%d %H:%M:%S'), time)
assert_equal(@expected.merge('pri' => 6), 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