zumobi 0.0.2 → 0.0.3

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.
@@ -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
- Rails.logger.send(name, e.message + "\n" + e.backtrace.join("\n"), &block)
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
- Airbrake.notify(e) if Object.const_defined?(:Airbrake)
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
@@ -1,3 +1,3 @@
1
1
  module Zumobi
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zumobi
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alx Dark