zumobi 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/zumobi/exception_handler.rb +17 -2
- data/lib/zumobi/version.rb +1 -1
- metadata +3 -3
@@ -1,9 +1,13 @@
|
|
1
1
|
require 'right_aws'
|
2
|
+
require 'socket'
|
3
|
+
require 'airbrake'
|
2
4
|
|
3
5
|
module Zumobi
|
4
6
|
|
5
7
|
class ExceptionHandler
|
6
8
|
|
9
|
+
@@ip_address = nil
|
10
|
+
|
7
11
|
# Network-related errors we'll skip...
|
8
12
|
EXCLUDED_EXCEPTIONS = [
|
9
13
|
Curl::Err::ConnectionFailedError.name,
|
@@ -20,15 +24,26 @@ class ExceptionHandler
|
|
20
24
|
RightAws::AwsError.name,
|
21
25
|
Timeout::Error.name ]
|
22
26
|
|
27
|
+
def self.ip_address
|
28
|
+
@@ip_address = @@ip_address || IPSocket.getaddress(Socket.gethostname)
|
29
|
+
end
|
30
|
+
|
23
31
|
def self.method_missing(name, *args, &block)
|
24
32
|
if [:debug, :info, :warn, :error, :fatal].include?(name)
|
33
|
+
c = SimpleConfig.for(:airbrake)
|
34
|
+
if (c.api_key.blank?)
|
35
|
+
raise "To log errors, add an airbrake config in simple config, with your app's api_key"
|
36
|
+
end
|
37
|
+
|
25
38
|
e = args[0]
|
26
39
|
unless EXCLUDED_EXCEPTIONS.include?(e.class.name)
|
27
40
|
# Note: Rails doesn't log the stacktrace... it's quite annoying
|
28
|
-
|
41
|
+
backtrace = e.backtrace ? ("\n" + e.backtrace.join("\n")) : ""
|
42
|
+
Rails.logger.send(name, e.message + backtrace, &block)
|
29
43
|
|
30
44
|
# Send to Airbrake
|
31
|
-
|
45
|
+
puts({:api_key => c.api_key, :environment_name => "#{ExceptionHandler.ip_address}"}.inspect)
|
46
|
+
Airbrake.notify(e, {:api_key => c.api_key, :environment_name => "#{ExceptionHandler.ip_address}"})
|
32
47
|
end
|
33
48
|
end
|
34
49
|
end
|
data/lib/zumobi/version.rb
CHANGED
metadata
CHANGED