logging-appenders-airbrake 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97f073a81dd1862e5c006694dbb3504a141f1a62
4
- data.tar.gz: b208c5332f9065293128d65dfb62357d455525d9
3
+ metadata.gz: 4bc8885d2e4b19e79b2910cec28b3ab3fc0276e5
4
+ data.tar.gz: b97e2651aa511cbec10d79c0b7f5e0dc3c6947c6
5
5
  SHA512:
6
- metadata.gz: 1f5b049f21615fbf3e913fb845d1a2f4bbd7a04ba4d4f48631797b4e1ed0a96ad1250c03484d04cc5cd65fd89bc8f765b11079de51eb8f07be0bac120f081098
7
- data.tar.gz: 6ca6d8a69d741182206c717edd31e33aa292f75d9adfe1356b22806d2d487f76359e792c3e89ea0a2909af5a21097aa8cf23a4582dfb3531c639106cddffba51
6
+ metadata.gz: 6d59b2e5b6616ff0e3807d9199cbdc0431531027f4bf82fe462ea821dc299807b03ee3a183f998862a5b7b72554711cc822226aae898152184c71e042bf824e0
7
+ data.tar.gz: 2ebb7acc146f01c27ceacbd7bbbc9ecad47a14d3d79385ee456844cdd0651b980015090c1fc08838678d36fbd7bf6a0f90ee84ce824b10578247f1fd3989cb15
@@ -5,6 +5,10 @@ rvm:
5
5
  - 2.0
6
6
  - 2.1
7
7
  - 2.2
8
+ - 2.3
9
+
10
+ before_install:
11
+ - gem update bundler
8
12
 
9
13
  notifications:
10
14
  email: false
data/Changes CHANGED
@@ -1,3 +1,9 @@
1
+ v0.0.3 2016-03-04
2
+ --------------------
3
+ Bug fixes:
4
+ * Call Airbrake.configure when Airbrake.sender is not set
5
+ * Under Rails 3, prevent exceptions from being sent to Airbrake twice when logger is wrapped by TaggedLogging
6
+
1
7
  v0.0.2 2015-03-21
2
8
  --------------------
3
9
  Bug fixes:
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/sshaw/logging-appenders-airbrake.svg?branch=master)](https://travis-ci.org/sshaw/logging-appenders-airbrake)
4
4
 
5
- Airbrake appender for [the Logging gem](https://github.com/TwP/logging).
5
+ Airbrake appender for [the Logging gem](https://github.com/TwP/logging). **Airbrake v5 is not supported.**
6
6
 
7
7
  ## Overview
8
8
 
@@ -37,9 +37,13 @@ to the `airbrake` method:
37
37
  Logging.appenders.airbrake("another_name", options)
38
38
 
39
39
  Airbrake configuration can be done via `Airbrake.configure` or via `Logging.appenders.airbrake`.
40
- All [`Airbrake::Configuration` options](http://www.rubydoc.info/gems/airbrake/Airbrake/Configuration) can be passed
40
+ All [`Airbrake::Configuration` options](http://www.rubydoc.info/gems/airbrake/4.3.0/Airbrake/Configuration) can be passed
41
41
  to the latter.
42
42
 
43
+ Internally `Airbrake.configure` will be called *only if* `Airbrake.sender` has not been set. This gives
44
+ [some options set by `Airbrake.configure`](http://www.rubydoc.info/gems/airbrake/4.3.0/Airbrake/Sender) precedence over those
45
+ passed into the logger.
46
+
43
47
  ## Using With `logging-rails`
44
48
 
45
49
  If you're already using Airbrake then your current Airbrake initializer will be used.
@@ -11,7 +11,7 @@ module Logging::Appenders
11
11
  end
12
12
 
13
13
  class Airbrake < Logging::Appender
14
- VERSION = "0.0.2"
14
+ VERSION = "0.0.3"
15
15
 
16
16
  # Ignore errors logged by an Airbrake sender
17
17
  INTERNAL_BT_FILTER = %r{:in\s+`send_to_airbrake'}.freeze
@@ -29,7 +29,7 @@ module Logging::Appenders
29
29
 
30
30
  args.compact!
31
31
  name = args.first.is_a?(String) ? args.shift : "airbrake"
32
- airbrake = args.last.is_a?(Hash) ? args.pop : {}
32
+ airbrake = args.last.is_a?(Hash) ? args.pop.dup : {}
33
33
 
34
34
  airbrake[:backtrace_filters] ||= []
35
35
  airbrake[:backtrace_filters] << AIRBRAKE_BT_FILTER
@@ -48,6 +48,10 @@ module Logging::Appenders
48
48
  end
49
49
  end
50
50
 
51
+ # We need a sender else errors will not be sent to Airbrake.
52
+ # This will create a sender that may use some of the given config.
53
+ ::Airbrake.configure(true) {} unless ::Airbrake.sender
54
+
51
55
  super(name, appender)
52
56
  end
53
57
 
@@ -8,10 +8,11 @@ module Logging
8
8
  config.after_initialize do |app|
9
9
  next unless defined?(::Airbrake::Rails::Middleware) && app.middleware.include?(::Airbrake::Rails::Middleware)
10
10
 
11
+ # Don't use is_a?, the logger maybe be wrapped in ActiveSupport::TaggedLogging
11
12
  log = app.env_config["action_dispatch.logger"]
12
- next unless log.is_a?(Logging::Logger)
13
+ next unless log.respond_to?(:appenders=) && log.respond_to?(:additive=)
13
14
 
14
- # After sending an exception to Airbrake its middleware passes the exception (`raise`es) it up
15
+ # After sending an exception to Airbrake its middleware passes the exception (`raise`es it) up
15
16
  # the stack. Rails' middleware (DebugException, ShowExceptions) ends up logging these as fatal,
16
17
  # which triggers the Airbrake appender. To avoid sending the exception twice we remove the appender.
17
18
  log.appenders = Logging.logger.root.appenders if log.appenders.none?
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "logging-appenders-airbrake"
7
- spec.version = "0.0.2"
7
+ spec.version = "0.0.3"
8
8
  spec.authors = ["Skye Shaw"]
9
9
  spec.email = ["skye.shaw@gmail.com"]
10
10
  spec.summary = %q{Airbrake appender for the Logging gem}
@@ -18,8 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
  spec.required_ruby_version = "> 1.8.7"
20
20
 
21
- spec.add_dependency "airbrake"
21
+ spec.add_dependency "airbrake", "~> 4.1"
22
22
  spec.add_dependency "logging"
23
23
  spec.add_development_dependency "bundler", "~> 1.6"
24
24
  spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "minitest", "~> 5.1"
25
26
  end
@@ -1,6 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require "minitest/autorun"
3
- require "minitest/mock"
4
3
 
5
4
  require "logging"
6
5
  require "logging/appenders/airbrake"
@@ -25,6 +24,8 @@ class TestAirbrake < MiniTest::Unit::TestCase
25
24
  refute_nil Logging.logger["airbrake"]
26
25
  assert_same app, Logging.appenders.airbrake
27
26
 
27
+ refute_nil Airbrake.sender
28
+
28
29
  assert_equal config[:api_key], Airbrake.configuration.api_key
29
30
  assert_equal config[:host], Airbrake.configuration.host
30
31
  config[:ignore].each do |name|
@@ -38,6 +39,8 @@ class TestAirbrake < MiniTest::Unit::TestCase
38
39
  refute_nil Logging.logger["sshaw"]
39
40
  refute_same app, Logging.appenders.airbrake
40
41
 
42
+ refute_nil Airbrake.sender
43
+
41
44
  assert_equal config[:api_key], Airbrake.configuration.api_key
42
45
  assert_equal config[:host], Airbrake.configuration.host
43
46
  config[:ignore].each do |name|
@@ -74,7 +77,17 @@ class TestAirbrake < MiniTest::Unit::TestCase
74
77
  log.error("some error")
75
78
  end
76
79
 
80
+ def test_custom_sender_not_overwritten
81
+ Airbrake.sender = FailingSender.new
82
+
83
+ log = Logging.logger[__method__]
84
+ log.add_appenders(appender)
85
+
86
+ assert_instance_of FailingSender, Airbrake.sender
87
+ end
88
+
77
89
  private
90
+
78
91
  def config
79
92
  @config ||= {
80
93
  :api_key => "X123",
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logging-appenders-airbrake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Skye Shaw
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-21 00:00:00.000000000 Z
11
+ date: 2016-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: airbrake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '4.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '4.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: logging
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.1'
69
83
  description: An appender for the Logging gem that sends all messages logged at the
70
84
  :error level to Airbrake
71
85
  email:
@@ -104,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
118
  version: '0'
105
119
  requirements: []
106
120
  rubyforge_project:
107
- rubygems_version: 2.4.5
121
+ rubygems_version: 2.5.1
108
122
  signing_key:
109
123
  specification_version: 4
110
124
  summary: Airbrake appender for the Logging gem