16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/logstash/filters/ruby_logger.rb', line 16
def filter(event)
ruby_logged = /\A(?<severity_letter>\w), +\[(?<time>[\d\-T.:]+) +#(?<pid>\d+)\] +(?<severity>(?i:DEBUG|INFO|WARN|ERROR|FATAL|UNKNOWN|ANY)) +-- +(?<progname>.*?): /
if ruby_log_match = event[@source].match(ruby_logged)
uninteresting_names = %w(severity_letter time)
interesting_names = ruby_log_match.names - uninteresting_names
event.to_hash.update(interesting_names.map { |name| {name => ruby_log_match[name]} }.inject({}, &:update))
event['@timestamp'] = Time.parse(ruby_log_match['time']).utc
event[@source] = ruby_log_match.post_match if @consume
end
end
|