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.



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

def initialize(key)
  @key = key
end

Instance Method Details

#evaluate(event) ⇒ Object



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

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