yell-adapters-gelf 1.2.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 677b6910aecfd33721a24f884185e2cf4e3a61a4
4
+ data.tar.gz: d58f6268acd53a1a99290cba4baf08aa37cc1b0d
5
+ SHA512:
6
+ metadata.gz: 02a53e6a1cf49307ca6f408f7c51359606d8c25e3bceccd094ceb0570defb625e3cfad9fd2a88546ee81ca65e430a3cd5f478516e1c230cb6cc876ff7831b2bc
7
+ data.tar.gz: 237c36afe90050199475f04067333c290803452f82e7754eddd0399ff4b80d5928a41647ddee8d9fce5028bff27f2a663851141a49ff5a593f457fecbe960f7f
@@ -23,7 +23,7 @@ module Yell #:nodoc:
23
23
 
24
24
  def send( *datagrams )
25
25
  datagrams.each do |d|
26
- @socket.send( d, 0, *host_and_port )
26
+ @socket.send(d, 0, *host_and_port)
27
27
  end
28
28
  end
29
29
 
@@ -60,17 +60,17 @@ module Yell #:nodoc:
60
60
 
61
61
  write do |event|
62
62
  message = format({
63
- 'version' => '1.0',
63
+ 'version' => '1.0',
64
64
 
65
- 'facility' => facility,
66
- 'level' => Severities[event.level],
67
- 'timestamp' => event.time.to_f,
68
- 'host' => event.hostname,
65
+ 'facility' => facility,
66
+ 'level' => Severities[event.level],
67
+ 'timestamp' => event.time.to_f,
68
+ 'host' => event.hostname,
69
69
 
70
- 'file' => event.file,
71
- 'line' => event.line,
72
- '_method' => event.method,
73
- '_pid' => event.pid
70
+ 'file' => event.file,
71
+ 'line' => event.line,
72
+ '_method' => event.method,
73
+ '_pid' => event.pid
74
74
  }, *event.messages )
75
75
 
76
76
  # https://github.com/Graylog2/graylog2-docs/wiki/GELF
@@ -12,21 +12,23 @@ describe Yell::Adapters::Gelf do
12
12
  end
13
13
  end
14
14
 
15
+ let(:logger) { Yell::Logger.new }
16
+
15
17
  before do
16
- stub( Yell::Adapters::Gelf::Sender ).new( anything ) { SenderStub }
18
+ stub(Yell::Adapters::Gelf::Sender).new(anything) { SenderStub }
17
19
  end
18
20
 
19
21
  context "a new Yell::Adapters::Gelf instance" do
20
22
  subject { Yell::Adapters::Gelf.new }
21
23
 
22
- it { subject.host.should == 'localhost' }
23
- it { subject.port.should == 12201 }
24
- it { subject.facility.should == 'yell' }
25
- it { subject.max_chunk_size.should == 1420 }
24
+ its(:host) { should == 'localhost' }
25
+ its(:port) { should == 12201 }
26
+ its(:facility) { should == 'yell' }
27
+ its(:max_chunk_size) { should == 1420 }
26
28
  end
27
29
 
28
30
  context :host do
29
- let( :adapter ) { Yell::Adapters::Gelf.new }
31
+ let(:adapter) { Yell::Adapters::Gelf.new }
30
32
  subject { adapter.host }
31
33
 
32
34
  before { adapter.host = 'hostname' }
@@ -35,7 +37,7 @@ describe Yell::Adapters::Gelf do
35
37
  end
36
38
 
37
39
  context :port do
38
- let( :adapter ) { Yell::Adapters::Gelf.new }
40
+ let(:adapter) { Yell::Adapters::Gelf.new }
39
41
  subject { adapter.port }
40
42
 
41
43
  before { adapter.port = 1234 }
@@ -44,7 +46,7 @@ describe Yell::Adapters::Gelf do
44
46
  end
45
47
 
46
48
  context :max_chunk_size do
47
- let( :adapter ) { Yell::Adapters::Gelf.new }
49
+ let(:adapter) { Yell::Adapters::Gelf.new }
48
50
  subject { adapter.max_chunk_size }
49
51
 
50
52
  context :wan do
@@ -64,15 +66,15 @@ describe Yell::Adapters::Gelf do
64
66
  end
65
67
 
66
68
  context :write do
67
- let( :event ) { Yell::Event.new( 1, 'Hello World' ) }
68
- let( :adapter ) { Yell::Adapters::Gelf.new }
69
+ let(:event) { Yell::Event.new(logger, 1, 'Hello World') }
70
+ let(:adapter) { Yell::Adapters::Gelf.new }
69
71
 
70
72
  context "single" do
71
- let( :datagrams ) { SenderStub.datagrams }
73
+ let(:datagrams) { SenderStub.datagrams }
72
74
 
73
75
  before do
74
- deflated = Zlib::Deflate.deflate( "*" * 1441000 ) # compresses to 1420 bytes
75
- mock( Zlib::Deflate ).deflate( anything ) { deflated }
76
+ deflated = Zlib::Deflate.deflate("*" * 1441000) # compresses to 1420 bytes
77
+ mock(Zlib::Deflate).deflate(anything) { deflated }
76
78
 
77
79
  adapter.write event
78
80
  end
@@ -86,16 +88,16 @@ describe Yell::Adapters::Gelf do
86
88
  end
87
89
 
88
90
  it "should be zipped" do
89
- datagrams[0][0..1].should == "\x78\x9c" # zlib header
91
+ datagrams[0][0..1].bytes.should == [0x78, 0x9C] # zlib header
90
92
  end
91
93
  end
92
94
 
93
95
  context "chunked" do
94
- let( :datagrams ) { SenderStub.datagrams }
96
+ let(:datagrams) { SenderStub.datagrams }
95
97
 
96
98
  before do
97
- deflated = Zlib::Deflate.deflate( "*" * 1442000 ) # compresses to 1421 bytes
98
- mock( Zlib::Deflate ).deflate( anything ) { deflated }
99
+ deflated = Zlib::Deflate.deflate("*" * 1442000) # compresses to 1421 bytes
100
+ mock(Zlib::Deflate).deflate(anything) { deflated }
99
101
 
100
102
  adapter.write event
101
103
  end
@@ -105,7 +107,7 @@ describe Yell::Adapters::Gelf do
105
107
  end
106
108
 
107
109
  it "should be multiple strings" do
108
- datagrams.each { |datagram| datagram.should be_kind_of String }
110
+ datagrams.each { |datagram| datagram.should be_kind_of(String) }
109
111
  end
110
112
 
111
113
  it "should be multiple GELF chunks" do
@@ -124,83 +126,83 @@ describe Yell::Adapters::Gelf do
124
126
  after { adapter.write event }
125
127
 
126
128
  it "should receive :version" do
127
- mock.proxy( adapter ).datagrams( hash_including('version' => '1.0') )
129
+ mock.proxy(adapter).datagrams( hash_including('version' => '1.0') )
128
130
  end
129
131
 
130
132
  it "should receive :facility" do
131
- mock.proxy( adapter ).datagrams( hash_including('facility' => adapter.facility) )
133
+ mock.proxy(adapter).datagrams( hash_including('facility' => adapter.facility) )
132
134
  end
133
135
 
134
136
  it "should receive :level" do
135
- mock.proxy( adapter ).datagrams( hash_including('level' => Yell::Adapters::Gelf::Severities[event.level]) )
137
+ mock.proxy(adapter).datagrams( hash_including('level' => Yell::Adapters::Gelf::Severities[event.level]) )
136
138
  end
137
139
 
138
140
  it "should receive :short_message" do
139
- mock.proxy( adapter ).datagrams( hash_including('short_message' => event.messages.first) )
141
+ mock.proxy(adapter).datagrams( hash_including('short_message' => event.messages.first) )
140
142
  end
141
143
 
142
144
  it "should receive :timestamp" do
143
- mock.proxy( adapter ).datagrams( hash_including('timestamp' => event.time.to_f) )
145
+ mock.proxy(adapter).datagrams( hash_including('timestamp' => event.time.to_f) )
144
146
  end
145
147
 
146
148
  it "should receive :host" do
147
- mock.proxy( adapter ).datagrams( hash_including('host' => event.hostname) )
149
+ mock.proxy(adapter).datagrams( hash_including('host' => event.hostname) )
148
150
  end
149
151
 
150
152
  it "should receive :file" do
151
- mock.proxy( adapter ).datagrams( hash_including('file' => event.file) )
153
+ mock.proxy(adapter).datagrams( hash_including('file' => event.file) )
152
154
  end
153
155
 
154
156
  it "should receive :line" do
155
- mock.proxy( adapter ).datagrams( hash_including('line' => event.line) )
157
+ mock.proxy(adapter).datagrams( hash_including('line' => event.line) )
156
158
  end
157
159
 
158
160
  it "should receive :method" do
159
- mock.proxy( adapter ).datagrams( hash_including('_method' => event.method) )
161
+ mock.proxy(adapter).datagrams( hash_including('_method' => event.method) )
160
162
  end
161
163
 
162
164
  it "should receive :pid" do
163
- mock.proxy( adapter ).datagrams( hash_including('_pid' => event.pid) )
165
+ mock.proxy(adapter).datagrams( hash_including('_pid' => event.pid) )
164
166
  end
165
167
 
166
168
  context "given a Hash" do
167
- let( :event ) { Yell::Event.new( 1, 'short_message' => 'Hello World', '_custom_field' => 'Custom Field' ) }
169
+ let(:event) { Yell::Event.new(logger, 1, 'short_message' => 'Hello World', '_custom_field' => 'Custom Field') }
168
170
 
169
171
  it "should receive :short_message" do
170
- mock.proxy( adapter ).datagrams( hash_including('short_message' => 'Hello World') )
172
+ mock.proxy(adapter).datagrams( hash_including('short_message' => 'Hello World') )
171
173
  end
172
174
 
173
175
  it "should receive :_custom_field" do
174
- mock.proxy( adapter ).datagrams( hash_including('_custom_field' => 'Custom Field') )
176
+ mock.proxy(adapter).datagrams( hash_including('_custom_field' => 'Custom Field') )
175
177
  end
176
178
  end
177
179
 
178
180
  context "given an Exception" do
179
- let( :exception ) { StandardError.new 'This is an error' }
180
- let( :event ) { Yell::Event.new( 1, exception ) }
181
+ let(:exception) { StandardError.new('This is an error') }
182
+ let(:event) { Yell::Event.new(logger, 1, exception) }
181
183
 
182
184
  before do
183
- mock( exception ).backtrace.times(any_times) { [:back, :trace] }
185
+ mock(exception).backtrace.times(any_times) { [:back, :trace] }
184
186
  end
185
187
 
186
188
  it "should receive :short_message" do
187
- mock.proxy( adapter ).datagrams( hash_including('short_message' => "#{exception.class}: #{exception.message}") )
189
+ mock.proxy(adapter).datagrams( hash_including('short_message' => "#{exception.class}: #{exception.message}") )
188
190
  end
189
191
 
190
192
  it "should receive :long_message" do
191
- mock.proxy( adapter ).datagrams( hash_including('long_message' => "back\ntrace") )
193
+ mock.proxy(adapter).datagrams( hash_including('long_message' => "back\ntrace") )
192
194
  end
193
195
  end
194
196
 
195
197
  context "given a Yell::Event with :options" do
196
- let( :event ) { Yell::Event.new( 1, 'Hello World', "_custom_field" => 'Custom Field' ) }
198
+ let(:event) { Yell::Event.new(logger, 1, 'Hello World', "_custom_field" => 'Custom Field') }
197
199
 
198
200
  it "should receive :short_message" do
199
- mock.proxy( adapter ).datagrams( hash_including('short_message' => 'Hello World') )
201
+ mock.proxy(adapter).datagrams( hash_including('short_message' => 'Hello World') )
200
202
  end
201
203
 
202
204
  it "should receive :_custom_field" do
203
- mock.proxy( adapter ).datagrams( hash_including('_custom_field' => 'Custom Field') )
205
+ mock.proxy(adapter).datagrams( hash_including('_custom_field' => 'Custom Field') )
204
206
  end
205
207
  end
206
208
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "yell-adapters-gelf"
5
- s.version = "1.2.0"
5
+ s.version = "2.0.0"
6
6
  s.authors = ["Rudolf Schmidt"]
7
7
 
8
8
  s.homepage = "http://rubygems.org/gems/yell"
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
 
18
18
  s.require_paths = ["lib"]
19
19
 
20
- s.add_runtime_dependency "yell", "~> 1.2"
20
+ s.add_runtime_dependency "yell", "~> 2.0"
21
21
  s.add_runtime_dependency "json"
22
22
  end
23
23
 
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yell-adapters-gelf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
5
- prerelease:
4
+ version: 2.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Rudolf Schmidt
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-28 00:00:00.000000000 Z
11
+ date: 2013-11-28 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: yell
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: '1.2'
19
+ version: '2.0'
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
- version: '1.2'
26
+ version: '2.0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: json
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: Graylog2 adapter for Yell
@@ -62,34 +57,28 @@ files:
62
57
  - yell-adapters-gelf.gemspec
63
58
  homepage: http://rubygems.org/gems/yell
64
59
  licenses: []
60
+ metadata: {}
65
61
  post_install_message:
66
62
  rdoc_options: []
67
63
  require_paths:
68
64
  - lib
69
65
  required_ruby_version: !ruby/object:Gem::Requirement
70
- none: false
71
66
  requirements:
72
- - - ! '>='
67
+ - - '>='
73
68
  - !ruby/object:Gem::Version
74
69
  version: '0'
75
- segments:
76
- - 0
77
- hash: 1468514528075820551
78
70
  required_rubygems_version: !ruby/object:Gem::Requirement
79
- none: false
80
71
  requirements:
81
- - - ! '>='
72
+ - - '>='
82
73
  - !ruby/object:Gem::Version
83
74
  version: '0'
84
- segments:
85
- - 0
86
- hash: 1468514528075820551
87
75
  requirements: []
88
76
  rubyforge_project: yell
89
- rubygems_version: 1.8.24
77
+ rubygems_version: 2.0.6
90
78
  signing_key:
91
- specification_version: 3
79
+ specification_version: 4
92
80
  summary: Yell - Your Extensible Logging Library
93
81
  test_files:
94
82
  - spec/spec_helper.rb
95
83
  - spec/yell/adapters/gelf_spec.rb
84
+ has_rdoc: