- start working on date support for Event#sprintf

This commit is contained in:
Jordan Sissel 2011-03-18 22:41:47 -07:00
parent c9edd1380a
commit f7c76431c9

View file

@ -134,7 +134,14 @@ class LogStash::Event
public
def sprintf(format)
return format.gsub(/%\{[^}]+\}/) do |tok|
# Take the inside of the %{ ... }
key = tok[2 ... -1]
if key[0,1] == "+"
# Use a time format.
# TODO(sissel): http://code.google.com/p/logstash/issues/detail?id=38
else
# Use an event field.
value = self[key]
if value.nil?
tok # leave the %{foo} if this field does not exist in this event.
@ -144,6 +151,7 @@ class LogStash::Event
value # otherwise return the value
end
end
end
end # def sprintf
public