Project

flume

0.0
No commit activity in last 3 years
No release in over 3 years
A Redis logger for Ruby/Rails
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
~> 0.13.2
>= 0
~> 2.14
~> 0.7.1

Runtime

~> 0.0.2
>= 0
~> 0.19.1
 Project Readme

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:

<tr>
  <td>:list</td>
  <td>Redis list to write to</td>
  <td>'flume:log'</td>
</tr>

<tr>
  <td>:cap</td>
  <td>Truncation size</td>
  <td>2 ** 16</td>
</tr>

<tr>
  <td>:step</td>
  <td>Truncation step</td>
  <td>0</td>
</tr>

<tr>
  <td>:cycle</td>
  <td>Truncation cyle</td>
  <td>2 ** 8</td>
</tr>
Name Description Default
:redis Redis instance to use Redis.new

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