lib/fluent/mixin/plaintextformatter.rb in fluent-mixin-plaintextformatter-0.2.5 vs lib/fluent/mixin/plaintextformatter.rb in fluent-mixin-plaintextformatter-0.2.6
- old
+ new
@@ -115,16 +115,24 @@
time_str + tag_str + stringify_record(record) + (@add_newline ? "\n" : '')
rescue JSON::GeneratorError => e
# partial character in source, but hit end
# source sequence is illegal/malformed utf-8
unless @suppress_log_broken_string
- $log.warn e.message + ", ignored", :error_class => e.class, :tag => tag, :record => record.inspect # quote explicitly
+ if self.respond_to?(:log)
+ log.warn e.message + ", ignored", :error_class => e.class, :tag => tag, :record => record.inspect # quote explicitly
+ else
+ $log.warn e.message + ", ignored", :error_class => e.class, :tag => tag, :record => record.inspect # quote explicitly
+ end
end
''
rescue ArgumentError => e
raise unless e.message == 'invalid byte sequence in UTF-8'
unless @suppress_log_broken_string
- $log.warn e.message + ", ignored", :error_class => e.class, :tag => tag, :record => record.inspect # quote explicitly
+ if self.respond_to?(:log)
+ log.warn e.message + ", ignored", :error_class => e.class, :tag => tag, :record => record.inspect # quote explicitly
+ else
+ $log.warn e.message + ", ignored", :error_class => e.class, :tag => tag, :record => record.inspect # quote explicitly
+ end
end
''
end
end
end