flume 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +10 -0
- data/LICENSE.txt +1 -1
- data/README.md +117 -6
- data/Rakefile +6 -0
- data/lib/flume/cli.rb +5 -1
- data/lib/flume/log_device.rb +5 -13
- data/lib/flume/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddf2433162e288204e46cbae028ba2c1f359138d
|
4
|
+
data.tar.gz: 91969dc4cdfe5231def129d64df04c362b2ccc1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 570916b46514d89aa96d46731e76801fc2dbd4ca39d0ded639c33c32dc969a7133fd4a89f9f410dbc2bbec8b32c7fa10db659671fa982e5e248bfd37fa1d4de4
|
7
|
+
data.tar.gz: f6e32fc33cdbb8b262cf9e412431b7cca23a51205360b4a2ea346318c201efaef35cfec3a417b8050769164cc4b79a552403ed68e938ecd782cb1fd80f650389
|
data/.travis.yml
ADDED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,113 @@
|
|
1
|
-
# Flume
|
1
|
+
# Flume [](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/
|
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
data/lib/flume/cli.rb
CHANGED
@@ -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
|
data/lib/flume/log_device.rb
CHANGED
@@ -12,19 +12,17 @@ module Flume
|
|
12
12
|
@config = OpenStruct.new(options)
|
13
13
|
block.call(@config) if block
|
14
14
|
|
15
|
-
@redis = @config
|
16
|
-
@cap = @config
|
17
|
-
@step = @config
|
18
|
-
@cycle = @config
|
19
|
-
@list = @config
|
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
|
|
data/lib/flume/version.rb
CHANGED
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.
|
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-
|
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
|