Class: LogStash::KeyNode

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/string_interpolation.rb

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ KeyNode

Returns a new instance of KeyNode.



102
103
104
# File 'lib/logstash/string_interpolation.rb', line 102

def initialize(key)
  @key = key
end

Instance Method Details

#evaluate(event) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/logstash/string_interpolation.rb', line 106

def evaluate(event)
  value = event[@key]

  case value
  when nil
    "%{#{@key}}"
  when Array
    value.join(",")
  when Hash
    LogStash::Json.dump(value)
  else
    value
  end
end