lib/fluent/plugin/out_map.rb in fluent-plugin-map-0.0.1 vs lib/fluent/plugin/out_map.rb in fluent-plugin-map-0.0.2

- old
+ new

@@ -10,23 +10,32 @@ super $log.debug { "map: #{@map}" } end def emit(tag, es, chain) - tuples = [] - es.each {|time, record| - new_tuple = eval(@map) - if @multi - tuples.concat new_tuple - else - tuples << new_tuple + begin + tuples = [] + es.each {|time, record| + new_tuple = eval(@map) + if @multi + tuples.concat new_tuple + else + tuples << new_tuple + end + } + tuples.each do |tag, time, record| + if time == nil or record == nil + raise SyntaxError.new + end + $log.trace { [tag, time, record].inspect } + Fluent::Engine::emit(tag, time, record) end - } - tuples.each do |tag, time, record| - $log.trace { [tag, time, record].inspect } - Fluent::Engine::emit(tag, time, record) + chain.next + tuples + rescue SyntaxError => e + chain.next + $log.error "Select_if command is syntax error: #{@map}" + e #for test end - chain.next - tuples end end end