Class: DataLogger::Sinks::RedisList
- Inherits:
-
Object
- Object
- DataLogger::Sinks::RedisList
- Defined in:
- lib/datalogger/sinks/redis/list.rb
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ RedisList
constructor
A new instance of RedisList.
- #log(component, data) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ RedisList
Returns a new instance of RedisList.
8 9 10 11 12 13 |
# File 'lib/datalogger/sinks/redis/list.rb', line 8 def initialize(opts={}) redis_url = opts[:redis_url] || "redis://localhost:6379" uri = URI.parse(redis_url) @redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password) @list = opts[:list] || 'logs' end |
Instance Method Details
#log(component, data) ⇒ Object
15 16 17 |
# File 'lib/datalogger/sinks/redis/list.rb', line 15 def log(component, data) @redis.rpush @list, data.merge(component: component).to_json end |