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.
@@ -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.1"
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"]
@@ -62,22 +62,33 @@ class Graylog2Exceptions
62
62
  }
63
63
 
64
64
  if err.backtrace && err.backtrace.size > 0
65
- opts[:full_message] = "Backtrace:\n" + err.backtrace.join("\n")
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] << "\n\nEnvironment:\n"
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
- assert_equal('nil', json["_env_nil"])
141
- assert_equal('"bar"', json["_env_str"])
142
- assert_equal('123', json["_env_int"])
143
- assert_equal('["a", 2]', json["_env_arr"])
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: friendlyfashion-graylog2_exceptions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: