Flume Build Status

An unfancy Redis logger for Ruby.

Works great with Rails, auto-truncates logs at a configurable size, and has a dead-simple CLI for tailing.

Usage:

Rails:

# config/application.rb
# or config/environments/{development|production|etc}.rb

config.logger = Flume.logger

# Or, with options:

config.logger = Flume.logger do |logger|
  logger.redis = Redis.new
  logger.list  = "#{Rails.env}:log"
  logger.cap   = 2 ** 16
end

Plain Old Ruby:

redis  = Redis.new
logger = Flume.logger redis: redis, list: 'myapp:log'
logger.write("my message")

# Alternatively, it can be configured with a block:

logger = Flume.logger do |config|
  config.redis = Redis.new
  config.list  = 'myapp:log'
end

# Or in combination:

logger = Flume.logger list: 'myapp:log' do |config|
  config.redis { Redis.new }
end

Options:

Name Description Default
:redis Redis instance to use Redis.new
:list Redis list to write to 'flume:log'
:cap Truncation size 2 ** 16
:step Truncation step 0
:cycle Truncation cyle 2 ** 8

CLI:

$ flume tail <LIST>
$ flume tail myapp:log
$ flume tail myapp:log -f
$ flume tail myapp:log -n 1000

To specify which Redis:

$ REDIS_URL=redis://12.34.56.78:9101 flume tail myapp:log

Why log to Redis?

Redis is cheap, ubiquitous, and centralized in most deployments, making it a great log target for tiny-to-small webapps. Also, its PubSub feature is perfect for tailing a list-based log.

Installation

Add this line to your application's Gemfile:

gem 'flume'

And then execute:

$ bundle

Or install it yourself as:

$ gem install flume

Contributing

  1. Fork it ( https://github.com/PrintReleaf/flume/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Shout out to @ahoward for Ledis. Flume started as a fork and owes its simplicity to Ledis's K.I.S.S approach.

License

MIT