lib/fluent/plugin/out_rdkafka.rb in fluent-plugin-kafka-0.12.3 vs lib/fluent/plugin/out_rdkafka.rb in fluent-plugin-kafka-0.12.4
- old
+ new
@@ -1,6 +1,7 @@
require 'thread'
+require 'logger'
require 'fluent/output'
require 'fluent/plugin/kafka_plugin_util'
require 'rdkafka'
require 'fluent/plugin/kafka_producer_ext'
@@ -89,11 +90,25 @@
def configure(conf)
super
log.instance_eval {
def add(level, &block)
- if block
+ return unless block
+
+ # Follow rdkakfa's log level. See also rdkafka-ruby's bindings.rb: https://github.com/appsignal/rdkafka-ruby/blob/e5c7261e3f2637554a5c12b924be297d7dca1328/lib/rdkafka/bindings.rb#L117
+ case level
+ when Logger::FATAL
+ self.fatal(block.call)
+ when Logger::ERROR
+ self.error(block.call)
+ when Logger::WARN
+ self.warn(block.call)
+ when Logger::INFO
self.info(block.call)
+ when Logger::DEBUG
+ self.debug(block.call)
+ else
+ self.trace(block.call)
end
end
}
Rdkafka::Config.logger = log
config = build_config