logstash_rails 0.3.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/logstash_rails.rb +0 -1
- data/lib/logstash_rails/version.rb +1 -1
- data/logstash_rails.gemspec +1 -2
- metadata +12 -48
- data/.gitignore +0 -17
- data/.rspec +0 -5
- data/.travis.yml +0 -5
- data/Gemfile +0 -11
- data/README.md +0 -140
- data/Rakefile +0 -18
- data/spec/lib/logstash_rails/formatter/basic_spec.rb +0 -21
- data/spec/lib/logstash_rails/formatter/flatten_params_spec.rb +0 -26
- data/spec/lib/logstash_rails/formatter/source_spec.rb +0 -19
- data/spec/lib/logstash_rails/transport/logfile_spec.rb +0 -23
- data/spec/lib/logstash_rails/transport/logstash_tcp_spec.rb +0 -59
- data/spec/lib/logstash_rails/transport/logstash_udp_spec.rb +0 -28
- data/spec/lib/logstash_rails/transport/redis_spec.rb +0 -51
- data/spec/lib/logstash_rails/transport_base_spec.rb +0 -33
- data/spec/spec_helper.rb +0 -16
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6df04b2809febaa3f72b82c7813fc447f960b13c
|
4
|
+
data.tar.gz: c7b2d9a0a7bffdcfab05a77def77674c48e054ce
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8faacf71f370e115b4f194f987509543d132de778173089a1db0f74eddca33c8ecc15b19534215f914b8f7f41a21a199cba0a8368307ad7b2b6c1765ced6bc12
|
7
|
+
data.tar.gz: 2ff83b67e3eaee14157297f68ffe4df8221b99114db0af22e64d3fd8adf2eea59eaa0723401179f140f68e7d470238f238b268c8491095c99e3fb5454f65dff2
|
data/lib/logstash_rails.rb
CHANGED
data/logstash_rails.gemspec
CHANGED
@@ -12,8 +12,7 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.homepage = "https://github.com/cmertz/logstash_rails"
|
13
13
|
gem.license = "GPL"
|
14
14
|
|
15
|
-
gem.files =
|
16
|
-
gem.test_files = gem.files.grep(%r{^spec/})
|
15
|
+
gem.files = Dir['lib/**/*'] + %w(LICENSE.txt logstash_rails.gemspec)
|
17
16
|
gem.require_paths = ["lib"]
|
18
17
|
|
19
18
|
gem.add_dependency('logstash-event', '~> 1.2.02')
|
metadata
CHANGED
@@ -1,46 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- cmertz
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-07-17 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: logstash-event
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 1.2.02
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 1.2.02
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: activesupport
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
description: Send events from Rails to Logstash without logger foo.
|
@@ -50,13 +45,7 @@ executables: []
|
|
50
45
|
extensions: []
|
51
46
|
extra_rdoc_files: []
|
52
47
|
files:
|
53
|
-
- .gitignore
|
54
|
-
- .rspec
|
55
|
-
- .travis.yml
|
56
|
-
- Gemfile
|
57
48
|
- LICENSE.txt
|
58
|
-
- README.md
|
59
|
-
- Rakefile
|
60
49
|
- lib/logstash_rails.rb
|
61
50
|
- lib/logstash_rails/formatter.rb
|
62
51
|
- lib/logstash_rails/formatter/basic.rb
|
@@ -71,54 +60,29 @@ files:
|
|
71
60
|
- lib/logstash_rails/transport_base.rb
|
72
61
|
- lib/logstash_rails/version.rb
|
73
62
|
- logstash_rails.gemspec
|
74
|
-
- spec/lib/logstash_rails/formatter/basic_spec.rb
|
75
|
-
- spec/lib/logstash_rails/formatter/flatten_params_spec.rb
|
76
|
-
- spec/lib/logstash_rails/formatter/source_spec.rb
|
77
|
-
- spec/lib/logstash_rails/transport/logfile_spec.rb
|
78
|
-
- spec/lib/logstash_rails/transport/logstash_tcp_spec.rb
|
79
|
-
- spec/lib/logstash_rails/transport/logstash_udp_spec.rb
|
80
|
-
- spec/lib/logstash_rails/transport/redis_spec.rb
|
81
|
-
- spec/lib/logstash_rails/transport_base_spec.rb
|
82
|
-
- spec/spec_helper.rb
|
83
63
|
homepage: https://github.com/cmertz/logstash_rails
|
84
64
|
licenses:
|
85
65
|
- GPL
|
66
|
+
metadata: {}
|
86
67
|
post_install_message:
|
87
68
|
rdoc_options: []
|
88
69
|
require_paths:
|
89
70
|
- lib
|
90
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
72
|
requirements:
|
93
|
-
- -
|
73
|
+
- - ">="
|
94
74
|
- !ruby/object:Gem::Version
|
95
75
|
version: '0'
|
96
|
-
segments:
|
97
|
-
- 0
|
98
|
-
hash: 3722539195248864863
|
99
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
-
none: false
|
101
77
|
requirements:
|
102
|
-
- -
|
78
|
+
- - ">="
|
103
79
|
- !ruby/object:Gem::Version
|
104
80
|
version: '0'
|
105
|
-
segments:
|
106
|
-
- 0
|
107
|
-
hash: 3722539195248864863
|
108
81
|
requirements: []
|
109
82
|
rubyforge_project:
|
110
|
-
rubygems_version:
|
83
|
+
rubygems_version: 2.2.2
|
111
84
|
signing_key:
|
112
|
-
specification_version:
|
85
|
+
specification_version: 4
|
113
86
|
summary: Send events from Rails to Logstash without logger foo.
|
114
|
-
test_files:
|
115
|
-
- spec/lib/logstash_rails/formatter/basic_spec.rb
|
116
|
-
- spec/lib/logstash_rails/formatter/flatten_params_spec.rb
|
117
|
-
- spec/lib/logstash_rails/formatter/source_spec.rb
|
118
|
-
- spec/lib/logstash_rails/transport/logfile_spec.rb
|
119
|
-
- spec/lib/logstash_rails/transport/logstash_tcp_spec.rb
|
120
|
-
- spec/lib/logstash_rails/transport/logstash_udp_spec.rb
|
121
|
-
- spec/lib/logstash_rails/transport/redis_spec.rb
|
122
|
-
- spec/lib/logstash_rails/transport_base_spec.rb
|
123
|
-
- spec/spec_helper.rb
|
87
|
+
test_files: []
|
124
88
|
has_rdoc:
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/README.md
DELETED
@@ -1,140 +0,0 @@
|
|
1
|
-
# LogstashRails
|
2
|
-
[![Gem Version](https://badge.fury.io/rb/logstash_rails.png)](http://badge.fury.io/rb/logstash_rails)
|
3
|
-
[![Build Status](https://secure.travis-ci.org/cmertz/logstash_rails.png)](http://travis-ci.org/cmertz/logstash_rails)
|
4
|
-
[![Coverage Status](https://coveralls.io/repos/cmertz/logstash_rails/badge.png)](https://coveralls.io/r/cmertz/logstash_rails)
|
5
|
-
[![Code Climate](https://codeclimate.com/github/cmertz/logstash_rails.png)](https://codeclimate.com/github/cmertz/logstash_rails)
|
6
|
-
[![Dependency Status](https://gemnasium.com/cmertz/logstash_rails.png)](https://gemnasium.com/cmertz/logstash_rails)
|
7
|
-
|
8
|
-
Send events from Rails to Logstash without logger foo.
|
9
|
-
|
10
|
-
LogstashRails uses `ActiveSupport::Notifications` to subscribe to events from *Rails* and push them to *Logstash*.
|
11
|
-
It emmits json formatted `Logstash::Event`.
|
12
|
-
|
13
|
-
There is no `Logger` configuration, logfile or filter in Logstash required.
|
14
|
-
|
15
|
-
## Contents
|
16
|
-
|
17
|
-
* [Usage](#usage)
|
18
|
-
* [API](#api)
|
19
|
-
* [Configuration](#configuration)
|
20
|
-
* [Examples](#examples)
|
21
|
-
* [Contributing](#contributing)
|
22
|
-
|
23
|
-
## Features
|
24
|
-
|
25
|
-
* fine grained control over which events will be subscribed to
|
26
|
-
* some json event format normalization to prevent troubles with `Elasticsearch`
|
27
|
-
* can be reconfigured at runtime
|
28
|
-
* tcp and udp transports for testing
|
29
|
-
|
30
|
-
## Usage
|
31
|
-
|
32
|
-
Add logstash-rails to your applications `Gemfile`
|
33
|
-
|
34
|
-
```ruby
|
35
|
-
gem 'logstash_rails'
|
36
|
-
```
|
37
|
-
|
38
|
-
and provide an initializer for configuration.
|
39
|
-
|
40
|
-
You will have to add redis as a dependency to your application in order to use the redis transport.
|
41
|
-
|
42
|
-
### API
|
43
|
-
|
44
|
-
`LogstashRails.configure(options_hash)` returns an configured instance of `LogstashRails::Transport`.
|
45
|
-
See [Configuration](#configuration) for the options.
|
46
|
-
|
47
|
-
`LogstashRails::Transport#destroy` releases all resources (e.g. closes sockets) and unsubscribes
|
48
|
-
from all events for this instance.
|
49
|
-
|
50
|
-
|
51
|
-
### Configuration
|
52
|
-
|
53
|
-
`LogstashRails.config`takes an options hash with the following options:
|
54
|
-
|
55
|
-
__transport__
|
56
|
-
|
57
|
-
redis, logstash-udp, logstash-tcp and logfile are available.
|
58
|
-
|
59
|
-
logstash-tcp and logstash-udp should only be used for testing since they produce significant runtime overhead.
|
60
|
-
|
61
|
-
__events__
|
62
|
-
|
63
|
-
list of event name patterns to subscribe to. `Regex` and `String` is
|
64
|
-
supported. Defaults to `[/.*/]`
|
65
|
-
|
66
|
-
See [Active Support Instrumentation](http://edgeguides.rubyonrails.org/active_support_instrumentation.html)
|
67
|
-
for the events that `Rails` emmits.
|
68
|
-
|
69
|
-
__flatten_params__
|
70
|
-
|
71
|
-
`true` or `false`, defaults to true
|
72
|
-
|
73
|
-
flatten the params hash of `process_action.action_controller` events. This gets rid of collisions in dynamic mappings in ElasticSearch
|
74
|
-
|
75
|
-
__logger__
|
76
|
-
|
77
|
-
logger to use in case of exceptions while pushing events to the transport
|
78
|
-
|
79
|
-
__transport specific options__
|
80
|
-
|
81
|
-
should be self explaining
|
82
|
-
|
83
|
-
redis:
|
84
|
-
* __host__
|
85
|
-
* __port__
|
86
|
-
* __redis_key__
|
87
|
-
|
88
|
-
logfile:
|
89
|
-
* __logfile__
|
90
|
-
|
91
|
-
|
92
|
-
logstash-tcp:
|
93
|
-
* __host__
|
94
|
-
* __port__
|
95
|
-
|
96
|
-
|
97
|
-
logstash-udp:
|
98
|
-
* __host__
|
99
|
-
* __port__
|
100
|
-
|
101
|
-
|
102
|
-
### Examples
|
103
|
-
|
104
|
-
The most basic configuration looks like:
|
105
|
-
|
106
|
-
```ruby
|
107
|
-
LogstashRails.config(transport: :logfile)
|
108
|
-
```
|
109
|
-
|
110
|
-
This will write _all_ events to `APP_ROOT/log/logstash_rails.log`
|
111
|
-
|
112
|
-
A more complete example looks like:
|
113
|
-
|
114
|
-
```ruby
|
115
|
-
if Rails.env.production?
|
116
|
-
LogstashRails.config(
|
117
|
-
transport: :redis,
|
118
|
-
host: '1.2.3.4',
|
119
|
-
port: 12345,
|
120
|
-
redis_key: 'my_key',
|
121
|
-
events: [/action_controller/]
|
122
|
-
)
|
123
|
-
end
|
124
|
-
```
|
125
|
-
|
126
|
-
This will only subscribe to events from `ActionController`.
|
127
|
-
|
128
|
-
|
129
|
-
## Contributing
|
130
|
-
|
131
|
-
1. Fork it.
|
132
|
-
2. Create a branch (`git checkout -b my_feature`)
|
133
|
-
3. Commit your changes (`git commit -am "Added ..."`)
|
134
|
-
4. Push to the branch (`git push origin my_feature`)
|
135
|
-
5. Open a Pull Request
|
136
|
-
6. Enjoy a refreshing Orangina and wait
|
137
|
-
|
138
|
-
## License
|
139
|
-
|
140
|
-
Licensed under the GNU General Public License version 3 (GPLv3). See [LICENSE.txt](/LICENSE.txt) for details.
|
data/Rakefile
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'bundler/gem_tasks'
|
2
|
-
require 'yard'
|
3
|
-
require 'rspec/core/rake_task'
|
4
|
-
|
5
|
-
RSpec::Core::RakeTask.new(:test)
|
6
|
-
|
7
|
-
YARD::Rake::YardocTask.new do |t|
|
8
|
-
t.name = 'doc'
|
9
|
-
end
|
10
|
-
|
11
|
-
desc 'cleanup working copy'
|
12
|
-
task :clean do
|
13
|
-
FileUtils.rm_rf %w(coverage doc pkg)
|
14
|
-
end
|
15
|
-
|
16
|
-
task :default do
|
17
|
-
system "rake -T"
|
18
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
describe LogstashRails::Formatter::Basic do
|
2
|
-
|
3
|
-
subject do
|
4
|
-
LogstashRails::Formatter.get.perform('event', Time.now, Time.now, 1, {request: 'toto'})
|
5
|
-
end
|
6
|
-
|
7
|
-
it 'deletes Rack::Request' do
|
8
|
-
subject.should_not include('request')
|
9
|
-
end
|
10
|
-
|
11
|
-
%w(message host process_id source).each do |field|
|
12
|
-
it "adds #{field}" do
|
13
|
-
subject.should include(field)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'has the event type as message' do
|
18
|
-
JSON.parse(subject)["message"].should eq 'event'
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
describe LogstashRails::Formatter::FlattenParams do
|
2
|
-
|
3
|
-
subject do
|
4
|
-
lambda do |payload|
|
5
|
-
LogstashRails::Formatter.get.perform('event', Time.now, Time.now, 1, payload)
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'flattens params' do
|
10
|
-
payload = {params:{a: {b: 1}, c: 2}}
|
11
|
-
|
12
|
-
result = subject.call(payload)
|
13
|
-
|
14
|
-
JSON.parse(result).should include({'params' => {'a__b' => 1, 'c' => 2}})
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'does not flatten params' do
|
18
|
-
formatter = LogstashRails::Formatter.get(flatten_params: false)
|
19
|
-
payload = {params:{a: {b: 1}, c: 2}}
|
20
|
-
|
21
|
-
result = formatter.perform('event', Time.now, Time.now, 1, payload)
|
22
|
-
|
23
|
-
JSON.parse(result).should include({'params' => {'a' => {'b' => 1}, 'c' => 2}})
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
describe LogstashRails::Formatter::Source do
|
2
|
-
|
3
|
-
subject do
|
4
|
-
lambda do |options, payload|
|
5
|
-
LogstashRails::Formatter.get(options).perform('event', Time.now, Time.now, 1, payload)
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'knows its source' do
|
10
|
-
result = subject.call({source: 'test'}, {})
|
11
|
-
JSON.parse(result).should include({'source' => 'test'})
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'can be disabled' do
|
15
|
-
result = subject.call({source: false}, {})
|
16
|
-
JSON.parse(result).keys.should_not include('source')
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
describe LogstashRails::Transport::Logfile do
|
2
|
-
|
3
|
-
let :logfile do
|
4
|
-
Tempfile.new(File.basename(__FILE__))
|
5
|
-
end
|
6
|
-
|
7
|
-
subject do
|
8
|
-
formatter = LogstashRails::Formatter.get
|
9
|
-
LogstashRails::Transport::Logfile.new(formatter, logfile: logfile)
|
10
|
-
end
|
11
|
-
|
12
|
-
it { should respond_to :push }
|
13
|
-
|
14
|
-
it 'writes events to a logfile' do
|
15
|
-
event = 'foobar_event'
|
16
|
-
|
17
|
-
subject.push(event)
|
18
|
-
|
19
|
-
logfile.rewind
|
20
|
-
logfile.read.should include(event)
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
describe LogstashRails::Transport::LogstashTcp do
|
2
|
-
|
3
|
-
before do
|
4
|
-
@server = TCPServer.new(9000)
|
5
|
-
|
6
|
-
@thread = Thread.new do
|
7
|
-
client = @server.accept
|
8
|
-
@received = client.gets
|
9
|
-
client.close
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
after do
|
14
|
-
@thread.kill
|
15
|
-
@server.close
|
16
|
-
end
|
17
|
-
|
18
|
-
let :logstash_tcp do
|
19
|
-
formatter = LogstashRails::Formatter.get
|
20
|
-
LogstashRails::Transport::LogstashTcp.new(formatter, port: 9000)
|
21
|
-
end
|
22
|
-
|
23
|
-
it do
|
24
|
-
logstash_tcp.should respond_to :push
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'uses Celluliod::IO if present' do
|
28
|
-
celluloid = double(:celluloid, new: double(:socket, close: nil, write: nil))
|
29
|
-
stub_const('Celluloid::IO::TCPSocket', celluloid)
|
30
|
-
|
31
|
-
celluloid.should_receive(:new)
|
32
|
-
|
33
|
-
logstash_tcp.push 'toto'
|
34
|
-
|
35
|
-
logstash_tcp.destroy
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should close the tcp socket' do
|
39
|
-
# initialize tcp socket
|
40
|
-
logstash_tcp.push 'toto'
|
41
|
-
|
42
|
-
socket = logstash_tcp.instance_variable_get(:@socket)
|
43
|
-
expect{ logstash_tcp.destroy }.to change{ socket.closed? }.from(false).to(true)
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'sends data over tcp' do
|
47
|
-
logstash_tcp.push 'toto'
|
48
|
-
logstash_tcp.destroy
|
49
|
-
@thread.join
|
50
|
-
@received.should eq 'toto'
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'lazily connects the socket' do
|
54
|
-
expect{ logstash_tcp.push 'toto' }.to change{
|
55
|
-
logstash_tcp.instance_variable_get(:@socket).class
|
56
|
-
}
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
describe LogstashRails::Transport::LogstashUdp do
|
2
|
-
|
3
|
-
subject do
|
4
|
-
formatter = LogstashRails::Formatter.get
|
5
|
-
LogstashRails::Transport::LogstashUdp.new(formatter, port: 9001)
|
6
|
-
end
|
7
|
-
|
8
|
-
it { should respond_to :push }
|
9
|
-
|
10
|
-
it 'sends data over udp' do
|
11
|
-
message = "toto"
|
12
|
-
socket = UDPSocket.new
|
13
|
-
socket.bind('127.0.0.1', 9001)
|
14
|
-
|
15
|
-
received = nil
|
16
|
-
thread = Thread.new do
|
17
|
-
received = socket.recvfrom(message.length).first
|
18
|
-
end
|
19
|
-
|
20
|
-
subject.push message
|
21
|
-
|
22
|
-
thread.join
|
23
|
-
socket.close
|
24
|
-
|
25
|
-
received.should eq message
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
describe LogstashRails::Transport::Redis do
|
2
|
-
|
3
|
-
before do
|
4
|
-
Redis::Connection::Memory.reset_all_databases
|
5
|
-
end
|
6
|
-
|
7
|
-
subject do
|
8
|
-
formatter = LogstashRails::Formatter.get
|
9
|
-
LogstashRails::Transport::Redis.new(
|
10
|
-
formatter,
|
11
|
-
redis: Redis.new,
|
12
|
-
redis_key: 'logstash',
|
13
|
-
raise_errors: true
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
|
-
it { should respond_to :push }
|
18
|
-
|
19
|
-
it 'writes events to a redis list' do
|
20
|
-
subject.push('foobar_event')
|
21
|
-
|
22
|
-
Redis.new.lpop('logstash').should eq 'foobar_event'
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'survives forking' do
|
26
|
-
r,w = IO.pipe
|
27
|
-
|
28
|
-
# use connection in parent process
|
29
|
-
subject.push 'foo'
|
30
|
-
Redis.new.lpop 'logstash'
|
31
|
-
|
32
|
-
fork do
|
33
|
-
# use connection in child process
|
34
|
-
subject.push 'bar'
|
35
|
-
|
36
|
-
w.write(Redis.new.lpop('logstash') == 'bar')
|
37
|
-
w.flush
|
38
|
-
|
39
|
-
# override exit hooks
|
40
|
-
SimpleCov.at_exit{}
|
41
|
-
Process.exit! true
|
42
|
-
end
|
43
|
-
|
44
|
-
w.close
|
45
|
-
|
46
|
-
r.read.should eq 'true'
|
47
|
-
|
48
|
-
Process.wait
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
describe LogstashRails::TransportBase do
|
2
|
-
|
3
|
-
subject do
|
4
|
-
LogstashRails
|
5
|
-
end
|
6
|
-
|
7
|
-
it 'raises if no transport is specified' do
|
8
|
-
expect { subject.config({}) }.to raise_error(KeyError)
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'handles all events by default' do
|
12
|
-
config = subject.config(transport: :redis)
|
13
|
-
|
14
|
-
config.should_receive(:push)
|
15
|
-
|
16
|
-
ActiveSupport::Notifications.instrument('foobar_event')
|
17
|
-
|
18
|
-
config.destroy
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'logs exceptions if a logger is given' do
|
22
|
-
logger = double(:logger)
|
23
|
-
config = subject.config(transport: :redis, logger: logger)
|
24
|
-
config.stub(:push).and_raise(ArgumentError.new)
|
25
|
-
|
26
|
-
logger.should_receive(:error)
|
27
|
-
|
28
|
-
ActiveSupport::Notifications.instrument('foobar_event')
|
29
|
-
|
30
|
-
config.destroy
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'coveralls'
|
2
|
-
require 'simplecov'
|
3
|
-
|
4
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
|
-
SimpleCov::Formatter::HTMLFormatter,
|
6
|
-
Coveralls::SimpleCov::Formatter
|
7
|
-
]
|
8
|
-
|
9
|
-
SimpleCov.start do
|
10
|
-
add_filter('spec')
|
11
|
-
end
|
12
|
-
|
13
|
-
require 'bundler'
|
14
|
-
Bundler.require
|
15
|
-
|
16
|
-
require 'logstash_rails'
|