lib/fluent/plugin/out_redis.rb in fluent-plugin-redis-0.2.0 vs lib/fluent/plugin/out_redis.rb in fluent-plugin-redis-0.2.1
- old
+ new
@@ -1,25 +1,30 @@
module Fluent
class RedisOutput < BufferedOutput
Fluent::Plugin.register_output('redis', self)
- attr_reader :host, :port, :db_number, :redis
+ attr_reader :redis
+ config_param :host, :string, :default => 'localhost'
+ config_param :port, :integer, :default => 6379
+ config_param :db_number, :integer, :default => 0
+
+ # To support log_level option implemented by Fluentd v0.10.43
+ unless method_defined?(:log)
+ define_method("log") { $log }
+ end
+
def initialize
super
require 'redis'
require 'msgpack'
end
def configure(conf)
super
- @host = conf.has_key?('host') ? conf['host'] : 'localhost'
- @port = conf.has_key?('port') ? conf['port'].to_i : 6379
- @db_number = conf.has_key?('db_number') ? conf['db_number'].to_i : nil
-
if conf.has_key?('namespace')
- $log.warn "namespace option has been removed from fluent-plugin-redis 0.1.3. Please add or remove the namespace '#{conf['namespace']}' manually."
+ log.warn "namespace option has been removed from fluent-plugin-redis 0.1.3. Please add or remove the namespace '#{conf['namespace']}' manually."
end
end
def start
super
@@ -28,9 +33,10 @@
:thread_safe => true, :db => @db_number)
end
def shutdown
@redis.quit
+ super
end
def format(tag, time, record)
identifier = [tag, time].join(".")
[identifier, record].to_msgpack