yell-adapters-gelf 0.9.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -0
- data/lib/yell/adapters/gelf.rb +25 -12
- data/spec/yell/adapters/gelf_spec.rb +41 -0
- data/yell-adapters-gelf.gemspec +5 -8
- metadata +65 -100
- data/lib/yell/adapters/gelf/version.rb +0 -13
data/Gemfile
CHANGED
data/lib/yell/adapters/gelf.rb
CHANGED
@@ -61,18 +61,19 @@ module Yell #:nodoc:
|
|
61
61
|
write do |event|
|
62
62
|
# https://github.com/Graylog2/graylog2-docs/wiki/GELF
|
63
63
|
_datagrams = datagrams(
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
64
|
+
{
|
65
|
+
'version' => '1.0',
|
66
|
+
|
67
|
+
'facility' => facility,
|
68
|
+
'level' => Severities[event.level],
|
69
|
+
'timestamp' => event.time.to_f,
|
70
|
+
'host' => event.hostname,
|
71
|
+
|
72
|
+
'file' => event.file,
|
73
|
+
'line' => event.line,
|
74
|
+
'_method' => event.method,
|
75
|
+
'_pid' => event.pid
|
76
|
+
}.merge( format(event.message) ).merge( format(event.options) )
|
76
77
|
)
|
77
78
|
|
78
79
|
sender.send( *_datagrams )
|
@@ -135,6 +136,18 @@ module Yell #:nodoc:
|
|
135
136
|
_datagrams
|
136
137
|
end
|
137
138
|
|
139
|
+
def format( message )
|
140
|
+
case message
|
141
|
+
when Hash
|
142
|
+
message
|
143
|
+
when Exception
|
144
|
+
{ "short_message" => "#{message.class}: #{message.message}" }.tap do |m|
|
145
|
+
m.merge!( "long_message" => message.backtrace.join("\n") ) if message.backtrace
|
146
|
+
end
|
147
|
+
else { "short_message" => message.to_s }
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
138
151
|
def uid
|
139
152
|
@uid += 1
|
140
153
|
end
|
@@ -162,6 +162,47 @@ describe Yell::Adapters::Gelf do
|
|
162
162
|
it "should receive :pid" do
|
163
163
|
mock.proxy( adapter ).datagrams( hash_including('_pid' => event.pid) )
|
164
164
|
end
|
165
|
+
|
166
|
+
context "given a Hash" do
|
167
|
+
let( :event ) { Yell::Event.new( 1, 'short_message' => 'Hello World', '_custom_field' => 'Custom Field' ) }
|
168
|
+
|
169
|
+
it "should receive :short_message" do
|
170
|
+
mock.proxy( adapter ).datagrams( hash_including('short_message' => 'Hello World') )
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should receive :_custom_field" do
|
174
|
+
mock.proxy( adapter ).datagrams( hash_including('_custom_field' => 'Custom Field') )
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
context "given an Exception" do
|
179
|
+
let( :exception ) { StandardError.new 'This is an error' }
|
180
|
+
let( :event ) { Yell::Event.new( 1, exception ) }
|
181
|
+
|
182
|
+
before do
|
183
|
+
mock( exception ).backtrace.times(any_times) { [:back, :trace] }
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should receive :short_message" do
|
187
|
+
mock.proxy( adapter ).datagrams( hash_including('short_message' => "#{exception.class}: #{exception.message}") )
|
188
|
+
end
|
189
|
+
|
190
|
+
it "should receive :long_message" do
|
191
|
+
mock.proxy( adapter ).datagrams( hash_including('long_message' => "back\ntrace") )
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
context "given a Yell::Event with :options" do
|
196
|
+
let( :event ) { Yell::Event.new( 1, 'Hello World', "_custom_field" => 'Custom Field' ) }
|
197
|
+
|
198
|
+
it "should receive :short_message" do
|
199
|
+
mock.proxy( adapter ).datagrams( hash_including('short_message' => 'Hello World') )
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should receive :_custom_field" do
|
203
|
+
mock.proxy( adapter ).datagrams( hash_including('_custom_field' => 'Custom Field') )
|
204
|
+
end
|
205
|
+
end
|
165
206
|
end
|
166
207
|
end
|
167
208
|
|
data/yell-adapters-gelf.gemspec
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
$:.push File.expand_path("../lib", __FILE__)
|
4
|
-
require "yell/adapters/gelf/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
6
|
s.name = "yell-adapters-gelf"
|
8
|
-
s.version =
|
7
|
+
s.version = "0.11.0"
|
9
8
|
s.authors = ["Rudolf Schmidt"]
|
10
9
|
|
11
10
|
s.homepage = "http://rubygems.org/gems/yell"
|
@@ -15,14 +14,12 @@ Gem::Specification.new do |s|
|
|
15
14
|
s.rubyforge_project = "yell"
|
16
15
|
|
17
16
|
s.files = `git ls-files`.split("\n")
|
18
|
-
s.
|
19
|
-
s.
|
17
|
+
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
19
|
+
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_runtime_dependency "yell", "0.
|
22
|
+
s.add_runtime_dependency "yell", "~> 0.11.0"
|
23
23
|
s.add_runtime_dependency "json"
|
24
|
-
|
25
|
-
s.add_development_dependency "rspec"
|
26
|
-
s.add_development_dependency "rr"
|
27
24
|
end
|
28
25
|
|
metadata
CHANGED
@@ -1,122 +1,87 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: yell-adapters-gelf
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.0
|
3
|
+
version: !ruby/object:Gem::Version
|
5
4
|
prerelease:
|
5
|
+
version: 0.11.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
8
|
-
- Rudolf Schmidt
|
7
|
+
authors:
|
8
|
+
- Rudolf Schmidt
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
version: '0'
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: rspec
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: rr
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
12
|
+
|
13
|
+
date: 2012-05-23 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: yell
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.11.0
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: json
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id002
|
78
37
|
description: Graylog2 adapter for Yell
|
79
38
|
email:
|
80
39
|
executables: []
|
40
|
+
|
81
41
|
extensions: []
|
42
|
+
|
82
43
|
extra_rdoc_files: []
|
83
|
-
|
84
|
-
|
85
|
-
- .
|
86
|
-
-
|
87
|
-
-
|
88
|
-
-
|
89
|
-
-
|
90
|
-
-
|
91
|
-
- lib/yell
|
92
|
-
- lib/yell/adapters/gelf
|
93
|
-
- spec/spec_helper.rb
|
94
|
-
- spec/yell/adapters/gelf_spec.rb
|
95
|
-
- yell-adapters-gelf.gemspec
|
44
|
+
|
45
|
+
files:
|
46
|
+
- .gitignore
|
47
|
+
- .travis.yml
|
48
|
+
- Gemfile
|
49
|
+
- LICENSE.txt
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- lib/yell-adapters-gelf.rb
|
53
|
+
- lib/yell/adapters/gelf.rb
|
54
|
+
- spec/spec_helper.rb
|
55
|
+
- spec/yell/adapters/gelf_spec.rb
|
56
|
+
- yell-adapters-gelf.gemspec
|
96
57
|
homepage: http://rubygems.org/gems/yell
|
97
58
|
licenses: []
|
59
|
+
|
98
60
|
post_install_message:
|
99
61
|
rdoc_options: []
|
100
|
-
|
101
|
-
|
102
|
-
|
62
|
+
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
66
|
none: false
|
104
|
-
requirements:
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "0"
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
72
|
none: false
|
110
|
-
requirements:
|
111
|
-
|
112
|
-
|
113
|
-
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: "0"
|
114
77
|
requirements: []
|
78
|
+
|
115
79
|
rubyforge_project: yell
|
116
|
-
rubygems_version: 1.8.
|
80
|
+
rubygems_version: 1.8.15
|
117
81
|
signing_key:
|
118
82
|
specification_version: 3
|
119
83
|
summary: Yell - Your Extensible Logging Library
|
120
|
-
test_files:
|
121
|
-
- spec/spec_helper.rb
|
122
|
-
- spec/yell/adapters/gelf_spec.rb
|
84
|
+
test_files:
|
85
|
+
- spec/spec_helper.rb
|
86
|
+
- spec/yell/adapters/gelf_spec.rb
|
87
|
+
has_rdoc:
|