flume 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a38d4970d9c2883c1ae6611901fb8cb19df0d71
4
- data.tar.gz: 482ef5efbe2401d919f95f8e4780ef8f6111fa74
3
+ metadata.gz: ddf2433162e288204e46cbae028ba2c1f359138d
4
+ data.tar.gz: 91969dc4cdfe5231def129d64df04c362b2ccc1f
5
5
  SHA512:
6
- metadata.gz: e1ff7e21fecf1eaf1747ad89bdc63747b425f88b549d5c0549bf4162e49fb3ab989f5b3aeef4f8472c952caa3c34e23d0cc273ec5cb315e3b973be9d768d05d8
7
- data.tar.gz: b172999e740555a080e73c80f0e90de64ae3365b95d5c14588f8790b3575b28e06e1ea4b06f8c36e4ea36f9e287480aed6ec7c809b91b4de132615c0f60a45f6
6
+ metadata.gz: 570916b46514d89aa96d46731e76801fc2dbd4ca39d0ded639c33c32dc969a7133fd4a89f9f410dbc2bbec8b32c7fa10db659671fa982e5e248bfd37fa1d4de4
7
+ data.tar.gz: f6e32fc33cdbb8b262cf9e412431b7cca23a51205360b4a2ea346318c201efaef35cfec3a417b8050769164cc4b79a552403ed68e938ecd782cb1fd80f650389
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ - jruby-19mode
5
+ - rbx-2
6
+ - ruby-head
7
+ - jruby-head
8
+ notifications:
9
+ recipients:
10
+ - tech@printreleaf.com
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Casey O'Hara
1
+ Copyright (c) 2014 PrintReleaf
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,6 +1,113 @@
1
- # Flume
1
+ # Flume [![Build Status](https://travis-ci.org/PrintReleaf/flume.png?branch=master)](https://travis-ci.org/PrintReleaf/flume)
2
+
3
+ An unfancy Redis logger for Ruby.
4
+
5
+ Works great with Rails, auto-truncates logs at a configurable size, and has a dead-simple CLI for tailing.
6
+
7
+ ### Usage:
8
+
9
+ **Rails**:
10
+
11
+ ```ruby
12
+ # config/application.rb
13
+ # or config/environments/{development|production|etc}.rb
14
+
15
+ config.logger = Flume.logger
16
+
17
+ # Or, with options:
18
+
19
+ config.logger = Flume.logger do |logger|
20
+ logger.redis = Redis.new
21
+ logger.list = "#{Rails.env}:log"
22
+ logger.cap = 2 ** 16
23
+ end
24
+ ```
25
+
26
+ **Plain Old Ruby**:
27
+
28
+ ```ruby
29
+ redis = Redis.new
30
+ logger = Flume.logger redis: redis, list: 'myapp:log'
31
+ logger.write("my message")
32
+
33
+ # Alternatively, it can be configured with a block:
34
+
35
+ logger = Flume.logger do |config|
36
+ config.redis = Redis.new
37
+ config.list = 'myapp:log'
38
+ end
39
+
40
+ # Or in combination:
41
+
42
+ logger = Flume.logger list: 'myapp:log' do |config|
43
+ config.redis { Redis.new }
44
+ end
45
+ ```
46
+
47
+ ### Options:
48
+
49
+ <table>
50
+ <thead>
51
+ <tr>
52
+ <th>Name</th>
53
+ <th>Description</th>
54
+ <th>Default</th>
55
+ </tr>
56
+ </thead>
57
+ <tbody>
58
+ <tr>
59
+ <td>:redis</td>
60
+ <td>Redis instance to use</td>
61
+ <td>Redis.new</td>
62
+ </tr>
63
+
64
+ <tr>
65
+ <td>:list</td>
66
+ <td>Redis list to write to</td>
67
+ <td>'flume:log'</td>
68
+ </tr>
69
+
70
+ <tr>
71
+ <td>:cap</td>
72
+ <td>Truncation size</td>
73
+ <td>2 ** 16</td>
74
+ </tr>
75
+
76
+ <tr>
77
+ <td>:step</td>
78
+ <td>Truncation step</td>
79
+ <td>0</td>
80
+ </tr>
81
+
82
+ <tr>
83
+ <td>:cycle</td>
84
+ <td>Truncation cyle</td>
85
+ <td>2 ** 8</td>
86
+ </tr>
87
+ </tbody>
88
+ </table>
89
+
90
+
91
+ ### CLI:
92
+
93
+ ```bash
94
+ $ flume tail <LIST>
95
+ $ flume tail myapp:log
96
+ $ flume tail myapp:log -f
97
+ $ flume tail myapp:log -n 1000
98
+ ```
99
+
100
+ To specify which Redis:
101
+
102
+ ```bash
103
+ $ REDIS_URL=redis://12.34.56.78:9101 flume tail myapp:log
104
+ ```
105
+
106
+
107
+ ### Why log to Redis?
108
+
109
+ Redis is cheap, ubiquitous, and centralized in most deployments, making it a great log target for tiny-to-small webapps. Also, its [PubSub](http://redis.io/topics/pubsub) feature is perfect for tailing a list-based log.
2
110
 
3
- TODO: Write a gem description
4
111
 
5
112
  ## Installation
6
113
 
@@ -16,14 +123,18 @@ Or install it yourself as:
16
123
 
17
124
  $ gem install flume
18
125
 
19
- ## Usage
20
-
21
- TODO: Write usage instructions here
22
126
 
23
127
  ## Contributing
24
128
 
25
- 1. Fork it ( https://github.com/[my-github-username]/flume/fork )
129
+ 1. Fork it ( https://github.com/PrintReleaf/flume/fork )
26
130
  2. Create your feature branch (`git checkout -b my-new-feature`)
27
131
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
132
  4. Push to the branch (`git push origin my-new-feature`)
29
133
  5. Create a new Pull Request
134
+
135
+ Shout out to @ahoward for [Ledis](https://github.com/ahoward/ledis). Flume started as a fork and owes its simplicity to Ledis's K.I.S.S approach.
136
+
137
+ ## License
138
+
139
+ MIT
140
+
data/Rakefile CHANGED
@@ -1,2 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
+ task :test do
4
+ sh "rspec spec"
5
+ end
6
+
7
+ task :default => :test
8
+
@@ -5,7 +5,6 @@ module Flume
5
5
  option :f, :type => :boolean, :default => false
6
6
  option :number, :type => :numeric, :default => 80, :aliases => :n
7
7
  def tail(list)
8
- puts options
9
8
  logger = Flume.logger :list => list
10
9
  puts logger.tail(options[:number])
11
10
 
@@ -17,5 +16,10 @@ module Flume
17
16
  end
18
17
  end
19
18
 
19
+ desc "version", "show Flume version and quit"
20
+ def version
21
+ puts "Flume #{Flume::VERSION}"
22
+ end
23
+
20
24
  end
21
25
  end
@@ -12,19 +12,17 @@ module Flume
12
12
  @config = OpenStruct.new(options)
13
13
  block.call(@config) if block
14
14
 
15
- @redis = @config[:redis] || proc { Redis.new }
16
- @cap = @config[:cap] || (2 ** 16)
17
- @step = @config[:step] || 0
18
- @cycle = @config[:cycle] || (2 ** 8)
19
- @list = @config[:list] || 'flume:log'
15
+ @redis = @config.redis || proc { Redis.new }
16
+ @cap = @config.cap || (2 ** 16)
17
+ @step = @config.step || 0
18
+ @cycle = @config.cycle || (2 ** 8)
19
+ @list = @config.list || 'flume:log'
20
20
  end
21
21
 
22
-
23
22
  def channel
24
23
  "flume:#{list}"
25
24
  end
26
25
 
27
-
28
26
  def write(message)
29
27
  begin
30
28
  redis.lpush(list, message)
@@ -43,17 +41,14 @@ module Flume
43
41
  self.step = (step + 1) % cycle
44
42
  end
45
43
 
46
-
47
44
  def close
48
45
  redis.quit rescue nil
49
46
  end
50
47
 
51
-
52
48
  def tail(n = 80)
53
49
  redis.lrange(list, 0, n - 1).reverse
54
50
  end
55
51
 
56
-
57
52
  def tailf(&block)
58
53
  begin
59
54
  redis.subscribe(channel) do |on|
@@ -68,16 +63,13 @@ module Flume
68
63
  end
69
64
  end
70
65
 
71
-
72
66
  def truncate(n)
73
67
  redis.ltrim(list, 0, n - 1)
74
68
  end
75
69
 
76
-
77
70
  def size
78
71
  redis.llen(list)
79
72
  end
80
-
81
73
  end
82
74
  end
83
75
 
@@ -1,3 +1,3 @@
1
1
  module Flume
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flume
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Casey O'Hara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-12 00:00:00.000000000 Z
11
+ date: 2014-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -131,6 +131,7 @@ extensions: []
131
131
  extra_rdoc_files: []
132
132
  files:
133
133
  - ".gitignore"
134
+ - ".travis.yml"
134
135
  - Gemfile
135
136
  - LICENSE.txt
136
137
  - README.md