trouble 0.0.10 → 0.0.11

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
  SHA1:
3
- metadata.gz: 0566c1a9f4781b362607e40b234e90092c302d48
4
- data.tar.gz: 7068f17853e2a4c21ccf64c5bdba79ce0b1dca21
3
+ metadata.gz: 7885087ed39042eab24b21212cebc7daaa8bb1ea
4
+ data.tar.gz: 3f6d91cea26e980c9b0f59107f456db15711bbab
5
5
  SHA512:
6
- metadata.gz: 7769108b3ed9e1014893b67e4f65d441cd5bf8f6c175f46ef4921974f335be03f9826cf7caf6200112c438e431c747274a03a5602d2f084fcef240d4628eb65e
7
- data.tar.gz: c33242b9396cb863fee041689cff9554e1fdf67aeafeeabb74650c02e20a532615ed15950464a72d82b7c4f244f4fc4e27c6c4f64c9c8bf14836e1a87f155722
6
+ metadata.gz: 40ecc987965b38c882c8be18731de28d2a6b32dc57ae26a6850f9b098f412758d20ba4eb26a52eafc52c72e05d0d1bbfc9a51b9f0a10ed1ed34d4cfff2b8bc96
7
+ data.tar.gz: 3b0708a2b5af377c89f1e00b6619bcc7ab637049a870972ef385e79b42dbc05f8c0d108915e181dde490f2a042c204ff55221e236d16611247d549090109c861
@@ -2,7 +2,7 @@ module Trouble
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 10
5
+ TINY = 11
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
8
8
  end
data/lib/trouble.rb CHANGED
@@ -19,7 +19,26 @@ module Trouble
19
19
  #
20
20
  def self.notify(exception, metadata = nil)
21
21
  exception.set_backtrace(caller) unless exception.backtrace
22
- notify! exception, metadata
22
+ notify_error_service(exception, metadata)
23
+ log_in_logger(exception, metadata)
24
+ increment_metric
25
+ end
26
+
27
+ # Public: Log the error in the logger and track as metric.
28
+ #
29
+ # exception - An instance of an Exception
30
+ # metadata - An Hash with arbitrary additional information (optional)
31
+ #
32
+ # Examples
33
+ #
34
+ # Trouble.log RuntimeError.new
35
+ # Trouble.log RuntimeError.new, some_idea_why_it_happened: "I don't know, but try this and that."
36
+ #
37
+ # Returns nothing.
38
+ #
39
+ def self.log(exception, metadata = nil)
40
+ exception.set_backtrace(caller) unless exception.backtrace
41
+ log_in_logger(exception, metadata)
23
42
  increment_metric
24
43
  end
25
44
 
@@ -27,8 +46,7 @@ module Trouble
27
46
 
28
47
  # Internal: Dispatch the Exception to the backend(s).
29
48
  #
30
- def self.notify!(exception, metadata)
31
- log(exception, metadata) if config.logger
49
+ def self.notify_error_service(exception, metadata)
32
50
  Bugsnag.notify(exception, metadata) if defined?(Bugsnag)
33
51
  end
34
52
 
@@ -40,8 +58,8 @@ module Trouble
40
58
 
41
59
  # Internal: Log to the current Logger.
42
60
  #
43
- def self.log(exception, metadata)
44
- config.logger.error "TROUBLE NOTIFICATION #{exception.inspect} at #{exception.backtrace.first} with metadata #{metadata.inspect}"
61
+ def self.log_in_logger(exception, metadata)
62
+ config.logger.error("TROUBLE LOG #{exception.inspect} at #{exception.backtrace.first} with metadata #{metadata.inspect}") if config.logger
45
63
  end
46
64
 
47
65
  end
@@ -38,15 +38,32 @@ describe Trouble do
38
38
  Bugsnag.stub!(:notify)
39
39
  end
40
40
 
41
- describe '.notify' do
42
- it 'uses Bugsnag as notification backend' do
43
- Bugsnag.should_receive(:notify).with(exception, metadata)
44
- trouble.notify exception, metadata
45
- end
41
+ it 'uses Bugsnag as notification backend' do
42
+ Bugsnag.should_receive(:notify).with(exception, metadata)
43
+ trouble.notify exception, metadata
46
44
  end
47
45
  end
48
46
  end
49
47
 
48
+ describe '.log' do
49
+
50
+ it 'does not notify the error service' do
51
+ Bugsnag.should_not_receive(:notify)
52
+ trouble.log exception, metadata
53
+ end
54
+
55
+ it 'increments the metric' do
56
+ trouble.should_receive(:increment_metric)
57
+ trouble.log exception, metadata
58
+ end
59
+
60
+ it 'logs with the configured logger' do
61
+ trouble.config.logger = logger
62
+ trouble.config.logger.should_receive(:error)
63
+ trouble.log exception, metadata
64
+ end
65
+ end
66
+
50
67
  describe '.config' do
51
68
  before do
52
69
  Trouble.reset!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trouble
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - bukowskis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-05 00:00:00.000000000 Z
11
+ date: 2015-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -95,3 +95,4 @@ signing_key:
95
95
  specification_version: 4
96
96
  summary: A generic abstraction layer for reporting errors and Exceptions.
97
97
  test_files: []
98
+ has_rdoc: