Sha256: 07cb911fe0e6945e8eda2f2ae7a4fc0190651a0c34019c26028a43aaa73121c5

Contents?: true

Size: 474 Bytes

Versions: 1

Compression:

Stored size: 474 Bytes

Contents

require 'logger'
require 'redis'

class Redis
  # Log device to log to a redis instance
  class Logger
    def initialize(log, options = {})
      @log = log
      @pubsub = options.delete(:pubsub)
      @redis = Redis.new(options)
    end

    def write(message)
      if @pubsub
        @redis.publish(@log, message)
      else
        @redis.rpush(@log, message)
      end
    end

    def close
      @redis.disconnect!
    end
  end
end

require 'redis/logger/version'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redis-logger-0.1.0 lib/redis/logger.rb