graylog2_exceptions 1.2.0 → 1.3.0
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.
- data/VERSION +1 -1
- data/graylog2_exceptions.gemspec +2 -2
- data/lib/graylog2_exceptions.rb +8 -8
- data/test/test_graylog2_exceptions.rb +28 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
data/graylog2_exceptions.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{graylog2_exceptions}
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Lennart Koopmann"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-03-15}
|
13
13
|
s.description = %q{A Rack middleware that sends every Exception as GELF message to your Graylog2 server}
|
14
14
|
s.email = %q{lennart@socketfeed.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/graylog2_exceptions.rb
CHANGED
@@ -39,16 +39,16 @@ class Graylog2Exceptions
|
|
39
39
|
|
40
40
|
def send_to_graylog2 err
|
41
41
|
begin
|
42
|
-
notifier = GELF::Notifier.new(@args
|
43
|
-
notifier.notify!(
|
44
|
-
|
42
|
+
notifier = GELF::Notifier.new(@args.delete(:hostname), @args.delete(:port), @args.delete(:max_chunk_size))
|
43
|
+
notifier.notify!({
|
44
|
+
:short_message => err.message,
|
45
45
|
:full_message => err.backtrace.join("\n"),
|
46
|
-
:facility => @args
|
47
|
-
:level => @args
|
48
|
-
:host => @args
|
46
|
+
:facility => @args.delete(:facility),
|
47
|
+
:level => @args.delete(:level),
|
48
|
+
:host => @args.delete(:local_app_name),
|
49
49
|
:file => err.backtrace[0].split(":")[0],
|
50
|
-
:line => err.backtrace[0].split(":")[1]
|
51
|
-
|
50
|
+
:line => err.backtrace[0].split(":")[1],
|
51
|
+
}.merge(@args))
|
52
52
|
rescue => i_err
|
53
53
|
puts "Graylog2 Exception logger. Could not send message: " + i_err.message
|
54
54
|
end
|
@@ -23,6 +23,13 @@ class TestGraylog2Exceptions < Test::Unit::TestCase
|
|
23
23
|
assert_equal 1, c.args[:level]
|
24
24
|
end
|
25
25
|
|
26
|
+
def test_add_custom_attributes_to_parameters
|
27
|
+
c = Graylog2Exceptions.new(nil, {:_app => "my_awesome_app", :_rails_env => "staging"})
|
28
|
+
|
29
|
+
assert_equal "my_awesome_app", c.args[:_app]
|
30
|
+
assert_equal "staging", c.args[:_rails_env]
|
31
|
+
end
|
32
|
+
|
26
33
|
def test_correct_parameters_when_not_custom_set
|
27
34
|
c = Graylog2Exceptions.new(nil, {})
|
28
35
|
|
@@ -64,6 +71,27 @@ class TestGraylog2Exceptions < Test::Unit::TestCase
|
|
64
71
|
assert_equal ex.backtrace[0].split(":")[0], json["file"]
|
65
72
|
end
|
66
73
|
|
74
|
+
def test_send_exception_to_graylog2_with_custom_attributes
|
75
|
+
ex = build_exception
|
76
|
+
|
77
|
+
c = Graylog2Exceptions.new(nil, {
|
78
|
+
:local_app_name => "machinexx", :level => 4, :facility => 'myfacility',
|
79
|
+
:_app => "my_awesome_app", :_rails_env => "staging"
|
80
|
+
})
|
81
|
+
sent = Zlib::Inflate.inflate(c.send_to_graylog2(ex).join)
|
82
|
+
json = JSON.parse(sent)
|
83
|
+
|
84
|
+
assert json["short_message"].include?('undefined method `klopfer!')
|
85
|
+
assert json["full_message"].include?('in `build_exception')
|
86
|
+
assert_equal 'myfacility', json["facility"]
|
87
|
+
assert_equal 3, json["level"]
|
88
|
+
assert_equal "machinexx", json["host"]
|
89
|
+
assert_equal ex.backtrace[0].split(":")[1], json["line"]
|
90
|
+
assert_equal ex.backtrace[0].split(":")[0], json["file"]
|
91
|
+
assert_equal 'my_awesome_app', json["_app"]
|
92
|
+
assert_equal 'staging', json["_rails_env"]
|
93
|
+
end
|
94
|
+
|
67
95
|
def test_invalid_port_detection
|
68
96
|
ex = build_exception
|
69
97
|
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
-
-
|
7
|
+
- 3
|
8
8
|
- 0
|
9
|
-
version: 1.
|
9
|
+
version: 1.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Lennart Koopmann
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-03-15 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|