Skip to content

Commit

Permalink
parser_syslog: Apply review for better variable name
Browse files Browse the repository at this point in the history
Signed-off-by: Masahiro Nakagawa <[email protected]>
  • Loading branch information
repeatedly committed Sep 6, 2019
1 parent 2bc4294 commit 60c838f
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/fluent/plugin/parser_syslog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,14 @@ def parse_rfc3164(text, &block)
end

# header part
time_diff = 15 # skip Mmm dd hh:mm:ss
time_end = text[cursor + time_diff]
time_size = 15 # skip Mmm dd hh:mm:ss
time_end = text[cursor + time_size]
if time_end == SPLIT_CHAR
time_str = text.slice(cursor, time_diff)
time_str = text.slice(cursor, time_size)
cursor += 16 # time + ' '
elsif time_end == '.'.freeze
# support subsecond time
i = text.index(SPLIT_CHAR, time_diff)
i = text.index(SPLIT_CHAR, time_size)
time_str = text.slice(cursor, i - cursor)
cursor = i + 1
else
Expand All @@ -195,9 +195,9 @@ def parse_rfc3164(text, &block)
yield nil, nil
return
end
host_diff = i - cursor
host = text.slice(cursor, host_diff)
cursor += (host_diff + 1)
host_size = i - cursor
host = text.slice(cursor, host_size)
cursor += host_size + 1

record = {'host' => host}
record['pri'] = pri if pri
Expand All @@ -210,19 +210,19 @@ def parse_rfc3164(text, &block)
else
if text[i - 1] == ':'.freeze
if text[i - 2] == ']'.freeze
j = text.index('['.freeze, cursor)
record['ident'] = text.slice(cursor, j - cursor)
record['pid'] = text.slice(j + 1, i - j - 3) # remove '[' / ']:'
left_braket_pos = text.index('['.freeze, cursor)
record['ident'] = text.slice(cursor, left_braket_pos - cursor)
record['pid'] = text.slice(left_braket_pos + 1, i - left_braket_pos - 3) # remove '[' / ']:'
else
record['ident'] = text.slice(cursor, i - cursor - 1)
end
text.slice(i + 1, text.bytesize)
else
if @support_colonless_ident
if text[i - 1] == ']'.freeze
j = text.index('['.freeze, cursor)
record['ident'] = text.slice(cursor, j - cursor)
record['pid'] = text.slice(j + 1, i - j - 2) # remove '[' / ']'
left_braket_pos = text.index('['.freeze, cursor)
record['ident'] = text.slice(cursor, left_braket_pos - cursor)
record['pid'] = text.slice(left_braket_pos + 1, i - left_braket_pos - 2) # remove '[' / ']'
else
record['ident'] = text.slice(cursor, i - cursor)
end
Expand Down

0 comments on commit 60c838f

Please sign in to comment.