exception_handling 2.5.0.pre.1 → 2.5.0.pre.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 267155818260bd0971adcfb3f325ce559c70b47fd362a8f80a2f92fc81117bf7
4
- data.tar.gz: 52532fdf7184f79c85bbd384340ce99d753cd3b964ea9e1808da77091c5827b1
3
+ metadata.gz: e1f2be68af4ed35506d1ecb517eb720a197a4d3c7d346eeb11c87d8a6e9abdf5
4
+ data.tar.gz: c87a3341b654ae7144f41888fc0e454953f52663a259f353405790c25d8596ba
5
5
  SHA512:
6
- metadata.gz: cf6315b8cf9c5bf2d1bae4732571ee0cc4609e57179c0935775b2b7435ebc44739ed3f61eb84f35adc22a59a7f643892f392f4d2e069ef672a17aa23c1753a67
7
- data.tar.gz: d61c96173c88073a5be405480aeadd9a997749bc0b811534abe9b549c281f07b64e096123822a8268c0deb78f8eff139debd4ed93f78576305ae3ebc9e533cc8
6
+ metadata.gz: 4d2b5d03154666523f7fe03321ad1d1fa28ac0ae00629249c21f9f73a330b6f325acfe1ce8b039df4f318b6ade3dd28373b476f87f12d46917016403fbc8a8d6
7
+ data.tar.gz: 1482537c680996153dd63c7edb30b43259789a16ff3f86b8a61b5cd8aab402a9c07905dbc7d0a945ea0b93fd0fea2ea3ec09bbe51b389fe440d9d58991f08bb9
@@ -9,6 +9,10 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
9
9
  - The `**log_context` passed to `log_error`/`log_warning`/`log_info` is now
10
10
  passed into `Honeybadger.notify()`, in `context: { log_context: ... }`.
11
11
 
12
+ ## [2.4.4] - 2020-08-10
13
+ ### Fixed
14
+ - `ExceptionHandling.logger = nil` no longer displays an "implicit extend" deprecation warning.
15
+
12
16
  ## [2.4.3] - 2020-05-14
13
17
  ### Deprecated
14
18
  - In `ExceptionHandling.logger=`, implicit `logger.extend ContextualLogger::LoggerMixin` is now deprecated.
@@ -29,7 +33,8 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
29
33
  ### Changed
30
34
  - No longer depends on hobo_support. Uses invoca-utils 0.3 instead.
31
35
 
32
- [2.5.0]: https://github.com/Invoca/exception_handling/compare/v2.4.3...v2.5.0
36
+ [2.5.0]: https://github.com/Invoca/exception_handling/compare/v2.4.4...v2.5.0
37
+ [2.4.4]: https://github.com/Invoca/exception_handling/compare/v2.4.3...v2.4.4
33
38
  [2.4.3]: https://github.com/Invoca/exception_handling/compare/v2.4.2...v2.4.3
34
39
  [2.4.2]: https://github.com/Invoca/exception_handling/compare/v2.4.1...v2.4.2
35
40
  [2.4.1]: https://github.com/Invoca/exception_handling/compare/v2.4.0...v2.4.1
@@ -8,7 +8,7 @@ GIT
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- exception_handling (2.5.0.pre.1)
11
+ exception_handling (2.5.0.pre.2)
12
12
  actionmailer (>= 4.2, < 7.0)
13
13
  actionpack (>= 4.2, < 7.0)
14
14
  activesupport (>= 4.2, < 7.0)
@@ -55,7 +55,7 @@ GEM
55
55
  builder (3.2.3)
56
56
  coderay (1.1.2)
57
57
  concurrent-ruby (1.1.5)
58
- contextual_logger (0.8.0)
58
+ contextual_logger (0.9.1)
59
59
  activesupport
60
60
  json
61
61
  crass (1.0.6)
@@ -57,7 +57,7 @@ module ExceptionHandling # never included
57
57
  Deprecation3_0 = ActiveSupport::Deprecation.new('3.0', 'exception_handling')
58
58
 
59
59
  def logger=(logger)
60
- @logger = if logger.is_a?(ContextualLogger::LoggerMixin)
60
+ @logger = if logger.nil? || logger.is_a?(ContextualLogger::LoggerMixin)
61
61
  logger
62
62
  else
63
63
  Deprecation3_0.deprecation_warning('implicit extend with ContextualLogger::LoggerMixin', 'extend your logger instance or include into your logger class first')
@@ -195,7 +195,7 @@ module ExceptionHandling # never included
195
195
  timestamp = set_log_error_timestamp
196
196
  exception_info = ExceptionInfo.new(ex, exception_context, timestamp,
197
197
  controller: controller || current_controller, data_callback: data_callback,
198
- log_context: log_context)
198
+ log_context: logger.current_context_for_thread.deep_merge(log_context))
199
199
 
200
200
  if stub_handler
201
201
  stub_handler.handle_stub_log_error(exception_info.data)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ExceptionHandling
4
- VERSION = '2.5.0.pre.1'
4
+ VERSION = '2.5.0.pre.2'
5
5
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Rake 11+ has a misfeature where @warning = true by default
4
+ # See https://github.com/ruby/rake/pull/97/files
5
+ # This causes all tests to be run with `ruby -w`, causing a huge number of warnings
6
+ # from gems we don't control and overwhelming our test output.
7
+ # This patch reverts that.
8
+
9
+ _ = Rake::TestTask
10
+
11
+ class Rake::TestTask
12
+ module SetWarningFalseMixin
13
+ def initialize(*args)
14
+ super
15
+ self.warning = false
16
+ end
17
+ end
18
+
19
+ prepend SetWarningFalseMixin
20
+ end
@@ -126,6 +126,11 @@ class ExceptionHandlingTest < ActiveSupport::TestCase
126
126
  assert_equal ancestors, ExceptionHandling.logger.singleton_class.ancestors.*.name
127
127
  end
128
128
 
129
+ should "allow logger = nil (no deprecation warning)" do
130
+ mock(STDERR).puts(/DEPRECATION WARNING/).never
131
+ ExceptionHandling.logger = nil
132
+ end
133
+
129
134
  should "[deprecated] mix in ContextualLogger::Mixin if not there" do
130
135
  mock(STDERR).puts(/DEPRECATION WARNING: implicit extend with ContextualLogger::LoggerMixin is deprecated and will be removed from exception_handling 3\.0/)
131
136
  logger = Logger.new('/dev/null')
@@ -616,68 +621,122 @@ class ExceptionHandlingTest < ActiveSupport::TestCase
616
621
  ExceptionHandling.log_error(exception_with_nil_message)
617
622
  end
618
623
 
619
- should "send error details and relevant context data to Honeybadger" do
620
- Time.now_override = Time.now
621
- env = { server: "fe98" }
622
- parameters = { advertiser_id: 435, controller: "some_controller" }
623
- session = { username: "jsmith" }
624
- request_uri = "host/path"
625
- controller = create_dummy_controller(env, parameters, session, request_uri)
626
- stub(ExceptionHandling).server_name { "invoca_fe98" }
627
-
628
- exception = StandardError.new("Some Exception")
629
- exception.set_backtrace([
630
- "test/unit/exception_handling_test.rb:847:in `exception_1'",
631
- "test/unit/exception_handling_test.rb:455:in `block (4 levels) in <class:ExceptionHandlingTest>'"
632
- ])
633
- exception_context = { "SERVER_NAME" => "exceptional.com" }
634
-
635
- honeybadger_data = nil
636
- mock(Honeybadger).notify.with_any_args do |data|
637
- honeybadger_data = data
624
+ context "with stubbed values" do
625
+ setup do
626
+ Time.now_override = Time.now
627
+ @env = { server: "fe98" }
628
+ @parameters = { advertiser_id: 435, controller: "some_controller" }
629
+ @session = { username: "jsmith" }
630
+ @request_uri = "host/path"
631
+ @controller = create_dummy_controller(@env, @parameters, @session, @request_uri)
632
+ stub(ExceptionHandling).server_name { "invoca_fe98" }
633
+
634
+ @exception = StandardError.new("Some Exception")
635
+ @exception.set_backtrace([
636
+ "test/unit/exception_handling_test.rb:847:in `exception_1'",
637
+ "test/unit/exception_handling_test.rb:455:in `block (4 levels) in <class:ExceptionHandlingTest>'"
638
+ ])
639
+ @exception_context = { "SERVER_NAME" => "exceptional.com" }
638
640
  end
639
- log_context = { log_source: "gem/listen", cuid: "AA12BC34DE" }
640
- ExceptionHandling.log_error(exception, exception_context, controller, **log_context) do |data|
641
- data[:scm_revision] = "5b24eac37aaa91f5784901e9aabcead36fd9df82"
642
- data[:user_details] = { username: "jsmith" }
643
- data[:event_response] = "Event successfully received"
644
- data[:other_section] = "This should not be included in the response"
641
+
642
+ should "send error details and relevant context data to Honeybadger with log_context" do
643
+ honeybadger_data = nil
644
+ mock(Honeybadger).notify.with_any_args do |data|
645
+ honeybadger_data = data
646
+ end
647
+ ExceptionHandling.logger.global_context = { service_name: "rails", region: "AWS-us-east-1" }
648
+ log_context = { log_source: "gem/listen", service_name: "bin/console" }
649
+ ExceptionHandling.log_error(@exception, @exception_context, @controller, **log_context) do |data|
650
+ data[:scm_revision] = "5b24eac37aaa91f5784901e9aabcead36fd9df82"
651
+ data[:user_details] = { username: "jsmith" }
652
+ data[:event_response] = "Event successfully received"
653
+ data[:other_section] = "This should not be included in the response"
654
+ end
655
+
656
+ expected_data = {
657
+ error_class: :"Test Exception",
658
+ error_message: "Some Exception",
659
+ controller: "some_controller",
660
+ exception: @exception,
661
+ context: {
662
+ timestamp: Time.now.to_i,
663
+ error_class: "StandardError",
664
+ server: "invoca_fe98",
665
+ exception_context: { "SERVER_NAME" => "exceptional.com" },
666
+ scm_revision: "5b24eac37aaa91f5784901e9aabcead36fd9df82",
667
+ notes: "this is used by a test",
668
+ user_details: { "username" => "jsmith" },
669
+ request: {
670
+ "params" => { "advertiser_id" => 435, "controller" => "some_controller" },
671
+ "rails_root" => "Rails.root not defined. Is this a test environment?",
672
+ "url" => "host/path"
673
+ },
674
+ session: {
675
+ "key" => nil,
676
+ "data" => { "username" => "jsmith" }
677
+ },
678
+ environment: {
679
+ "SERVER_NAME" => "exceptional.com"
680
+ },
681
+ backtrace: [
682
+ "test/unit/exception_handling_test.rb:847:in `exception_1'",
683
+ "test/unit/exception_handling_test.rb:455:in `block (4 levels) in <class:ExceptionHandlingTest>'"
684
+ ],
685
+ event_response: "Event successfully received",
686
+ log_context: { "service_name" => "bin/console", "region" => "AWS-us-east-1", "log_source" => "gem/listen" }
687
+ }
688
+ }
689
+ assert_equal_with_diff expected_data, honeybadger_data
645
690
  end
646
691
 
647
- expected_data = {
648
- error_class: :"Test Exception",
649
- error_message: "Some Exception",
650
- controller: "some_controller",
651
- exception: exception,
652
- context: {
653
- timestamp: Time.now.to_i,
654
- error_class: "StandardError",
655
- server: "invoca_fe98",
656
- exception_context: { "SERVER_NAME" => "exceptional.com" },
657
- scm_revision: "5b24eac37aaa91f5784901e9aabcead36fd9df82",
658
- notes: "this is used by a test",
659
- user_details: { "username" => "jsmith" },
660
- request: {
661
- "params" => { "advertiser_id" => 435, "controller" => "some_controller" },
662
- "rails_root" => "Rails.root not defined. Is this a test environment?",
663
- "url" => "host/path"
664
- },
665
- session: {
666
- "key" => nil,
667
- "data" => { "username" => "jsmith" }
668
- },
669
- environment: {
670
- "SERVER_NAME" => "exceptional.com"
671
- },
672
- backtrace: [
673
- "test/unit/exception_handling_test.rb:847:in `exception_1'",
674
- "test/unit/exception_handling_test.rb:455:in `block (4 levels) in <class:ExceptionHandlingTest>'"
675
- ],
676
- event_response: "Event successfully received",
677
- log_context: { "log_source" => "gem/listen", "cuid" => "AA12BC34DE" }
692
+ should "send error details and relevant context data to Honeybadger with empty log_context" do
693
+ honeybadger_data = nil
694
+ mock(Honeybadger).notify.with_any_args do |data|
695
+ honeybadger_data = data
696
+ end
697
+ ExceptionHandling.logger.global_context = {}
698
+ log_context = {}
699
+ ExceptionHandling.log_error(@exception, @exception_context, @controller, **log_context) do |data|
700
+ data[:scm_revision] = "5b24eac37aaa91f5784901e9aabcead36fd9df82"
701
+ data[:user_details] = { username: "jsmith" }
702
+ data[:event_response] = "Event successfully received"
703
+ data[:other_section] = "This should not be included in the response"
704
+ end
705
+
706
+ expected_data = {
707
+ error_class: :"Test Exception",
708
+ error_message: "Some Exception",
709
+ controller: "some_controller",
710
+ exception: @exception,
711
+ context: {
712
+ timestamp: Time.now.to_i,
713
+ error_class: "StandardError",
714
+ server: "invoca_fe98",
715
+ exception_context: { "SERVER_NAME" => "exceptional.com" },
716
+ scm_revision: "5b24eac37aaa91f5784901e9aabcead36fd9df82",
717
+ notes: "this is used by a test",
718
+ user_details: { "username" => "jsmith" },
719
+ request: {
720
+ "params" => { "advertiser_id" => 435, "controller" => "some_controller" },
721
+ "rails_root" => "Rails.root not defined. Is this a test environment?",
722
+ "url" => "host/path"
723
+ },
724
+ session: {
725
+ "key" => nil,
726
+ "data" => { "username" => "jsmith" }
727
+ },
728
+ environment: {
729
+ "SERVER_NAME" => "exceptional.com"
730
+ },
731
+ backtrace: [
732
+ "test/unit/exception_handling_test.rb:847:in `exception_1'",
733
+ "test/unit/exception_handling_test.rb:455:in `block (4 levels) in <class:ExceptionHandlingTest>'"
734
+ ],
735
+ event_response: "Event successfully received"
736
+ }
678
737
  }
679
- }
680
- assert_equal_with_diff expected_data, honeybadger_data
738
+ assert_equal_with_diff expected_data, honeybadger_data
739
+ end
681
740
  end
682
741
 
683
742
  context "with post_log_error_hook set" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exception_handling
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0.pre.1
4
+ version: 2.5.0.pre.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Invoca
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-18 00:00:00.000000000 Z
11
+ date: 2020-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -150,6 +150,7 @@ files:
150
150
  - lib/exception_handling/version.rb
151
151
  - test/helpers/controller_helpers.rb
152
152
  - test/helpers/exception_helpers.rb
153
+ - test/rake_test_warning_false.rb
153
154
  - test/test_helper.rb
154
155
  - test/unit/exception_handling/exception_catalog_test.rb
155
156
  - test/unit/exception_handling/exception_description_test.rb
@@ -191,6 +192,7 @@ summary: Invoca's exception handling logger/emailer layer, based on exception_no
191
192
  test_files:
192
193
  - test/helpers/controller_helpers.rb
193
194
  - test/helpers/exception_helpers.rb
195
+ - test/rake_test_warning_false.rb
194
196
  - test/test_helper.rb
195
197
  - test/unit/exception_handling/exception_catalog_test.rb
196
198
  - test/unit/exception_handling/exception_description_test.rb