friendlyfashion-graylog2_exceptions 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/graylog2_exceptions.gemspec +1 -1
- data/lib/graylog2_exceptions.rb +14 -3
- data/test/test_graylog2_exceptions.rb +16 -6
- metadata +1 -1
data/graylog2_exceptions.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{friendlyfashion-graylog2_exceptions}
|
8
|
-
s.version = "1.3.
|
8
|
+
s.version = "1.3.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Laurynas Butkus", "Tomas Didziokas", "Justas Janauskas", "Edvinas Bartkus"]
|
data/lib/graylog2_exceptions.rb
CHANGED
@@ -62,22 +62,33 @@ class Graylog2Exceptions
|
|
62
62
|
}
|
63
63
|
|
64
64
|
if err.backtrace && err.backtrace.size > 0
|
65
|
-
opts[:full_message] = "
|
65
|
+
opts[:full_message] = "-------------------------------\n"
|
66
|
+
opts[:full_message] << "Backtrace:\n"
|
67
|
+
opts[:full_message] << "-------------------------------\n\n"
|
68
|
+
opts[:full_message] << err.backtrace.join("\n")
|
69
|
+
opts[:full_message] << "\n"
|
70
|
+
|
66
71
|
opts[:file] = err.backtrace[0].split(":")[0]
|
67
72
|
opts[:line] = err.backtrace[0].split(":")[1]
|
68
73
|
end
|
69
74
|
|
70
75
|
if env and env.size > 0
|
71
76
|
opts[:full_message] ||= ""
|
72
|
-
opts[:full_message] << "
|
77
|
+
opts[:full_message] << "-------------------------------\n"
|
78
|
+
opts[:full_message] << "Environment:\n"
|
79
|
+
opts[:full_message] << "-------------------------------\n\n"
|
73
80
|
|
74
81
|
env.each do |k, v|
|
75
82
|
begin
|
76
|
-
opts[:full_message] << "#{k}: #{v}\n"
|
83
|
+
opts[:full_message] << " * #{k}: #{v}\n"
|
77
84
|
#opts[:full_message] << "#{k}: #{v.inspect}\n"
|
78
85
|
rescue
|
79
86
|
end
|
80
87
|
end
|
88
|
+
|
89
|
+
opts[:full_message] << "\n"
|
90
|
+
opts[:full_message] << " * Process: #{$$}\n"
|
91
|
+
opts[:full_message] << " * Server: #{`hostname`.chomp}\n"
|
81
92
|
end
|
82
93
|
|
83
94
|
notifier.notify!(opts.merge(@extra_args))
|
@@ -137,15 +137,25 @@ class TestGraylog2Exceptions < Test::Unit::TestCase
|
|
137
137
|
|
138
138
|
sent = Zlib::Inflate.inflate(c.send_to_graylog2(ex, data).join)
|
139
139
|
json = JSON.parse(sent)
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
assert_equal('{"a"=>1}', json["_env_hash"])
|
145
|
-
assert_match(/#<Object:.*>/, json["_env_obj"])
|
140
|
+
|
141
|
+
assert json["full_message"].include?('123')
|
142
|
+
assert json["full_message"].include?('bad')
|
143
|
+
|
146
144
|
assert ! json.has_key?("_env_bad")
|
147
145
|
end
|
148
146
|
|
147
|
+
def test_send_pid_to_graylog
|
148
|
+
ex = build_exception
|
149
|
+
|
150
|
+
c = Graylog2Exceptions.new(nil)
|
151
|
+
env = { 'test' => 1 }
|
152
|
+
sent = Zlib::Inflate.inflate(c.send_to_graylog2(ex, env).join)
|
153
|
+
json = JSON.parse(sent)
|
154
|
+
|
155
|
+
assert json["full_message"].include?("Process: #{$$}")
|
156
|
+
assert json["full_message"].include?("Server: #{`hostname`.chomp}")
|
157
|
+
end
|
158
|
+
|
149
159
|
def test_invalid_port_detection
|
150
160
|
ex = build_exception
|
151
161
|
|