lib/logstash/codecs/google_appengine.rb in logstash-codec-google_appengine-1.1.0 vs lib/logstash/codecs/google_appengine.rb in logstash-codec-google_appengine-1.2.0
- old
+ new
@@ -11,19 +11,25 @@
def register
@json = LogStash::Codecs::JSON.new
end
def decode(data)
- @json.decode(data) do |json|
- if is_parse_failure(json)
- return yield json
+ begin
+ @json.decode(data) do |json|
+ if is_parse_failure(json)
+ return yield json
+ end
+ flatten(json).each { |flattenedJson|
+ yield LogStash::Event.new(flattenedJson)
+ }
end
- flatten(json).each { |flattenedJson|
- yield LogStash::Event.new(flattenedJson)
- }
+ rescue => e
+ @logger.info("Failed to process data", :error => e, :data => data)
+ yield LogStash::Event.new("message" => data, "tags" => ["_googleappengineparsefailure"])
end
end
end
+
private
def is_parse_failure(event)
event["tags"] && event["tags"].include?("_jsonparsefailure")