exceptions 0.0.9 → 0.0.10
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 +4 -4
- data/LICENSE +21 -0
- data/README.md +1 -0
- data/exceptions.gemspec +10 -10
- data/lib/exceptions/backends/log_result.rb +47 -0
- data/lib/exceptions/version.rb +1 -1
- data/lib/exceptions.rb +9 -1
- data/spec/exceptions/backends/log_result_spec.rb +19 -0
- metadata +14 -12
- data/LICENSE.txt +0 -22
- data/lib/exceptions/backends.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4185a231138c29c90b691eff7cc08d4242afa51
|
4
|
+
data.tar.gz: d1651725b49071006d7c0e815c2ab2baed52ab46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1d68b63aac5e2f604f74ad3285f37e4775c456b3232d83857a981c83b56e354ee8c96c8ddc380fb523a6a952477a4df6dd81008df6468a9dfedb430454aaf33
|
7
|
+
data.tar.gz: 65ff061af915bb17cf55b2b39dbbdc9da2be7723ad810367f394f632f01f8c5d817c3a574f45dccd261fd966b842abe284142dd049f97621550395782536c462
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Remind101, Inc.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -33,6 +33,7 @@ happens when `Exceptions.notify` is called. The following backends are provided:
|
|
33
33
|
* **Logger**: This backend will log the exception to stdout.
|
34
34
|
* **Honeybadger**: This backend will send the exception to honeybadger using the [honeybadger-ruby](https://github.com/honeybadger-io/honeybadger-ruby) gem.
|
35
35
|
* **Multi**: A meta backend to compose other backends into a single backend.
|
36
|
+
* **LogResult**: Another meta backend that wraps an existing backend to log the result in [logfmt](https://brandur.org/logfmt).
|
36
37
|
|
37
38
|
## Usage
|
38
39
|
|
data/exceptions.gemspec
CHANGED
@@ -4,22 +4,22 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'exceptions/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'exceptions'
|
8
8
|
spec.version = Exceptions::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Eric J. Holmes']
|
10
|
+
spec.email = ['eric@ejholmes.net']
|
11
11
|
spec.description = %q{Exceptions is a Ruby gem for exception tracking.}
|
12
12
|
spec.summary = %q{Exceptions is a Ruby gem for exception tracking.}
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
13
|
+
spec.homepage = 'https://github.com/remind101/exceptions'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.1.0'
|
24
|
+
spec.add_development_dependency 'honeybadger', '~> 1.9.5'
|
25
25
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module Exceptions
|
4
|
+
module Backends
|
5
|
+
# Public: LogResult is an implementation of the Backend interface the wraps an existing backend and logs
|
6
|
+
# the result id and url.
|
7
|
+
class LogResult < Backend
|
8
|
+
attr_reader :backend, :logger
|
9
|
+
|
10
|
+
def initialize(backend, logger = ::Logger.new(STDOUT))
|
11
|
+
@backend = backend
|
12
|
+
@logger = logger
|
13
|
+
end
|
14
|
+
|
15
|
+
def notify(exception, options = {})
|
16
|
+
backend.notify(exception, options).tap do |result|
|
17
|
+
log exception, result
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def rack_exception(exception, env)
|
22
|
+
backend.rack_exception(exception, env).tap do |result|
|
23
|
+
log exception, result
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def context(*args)
|
28
|
+
backend.context(*args)
|
29
|
+
end
|
30
|
+
|
31
|
+
def clear_context(*args)
|
32
|
+
backend.clear_context(*args)
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def log(exception, result)
|
38
|
+
logger.info "at=exception exception=#{exception.class} message=\"#{exception}\" " + \
|
39
|
+
"exception-id=#{result.id} url=#{result.url} source=#{source} count#exception=1" if result.ok?
|
40
|
+
end
|
41
|
+
|
42
|
+
def source
|
43
|
+
''
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/exceptions/version.rb
CHANGED
data/lib/exceptions.rb
CHANGED
@@ -2,11 +2,19 @@ require 'exceptions/version'
|
|
2
2
|
require 'exceptions/configuration'
|
3
3
|
require 'exceptions/result'
|
4
4
|
require 'exceptions/backend'
|
5
|
-
require 'exceptions/backends'
|
6
5
|
|
7
6
|
require 'rack/exceptions'
|
8
7
|
|
9
8
|
module Exceptions
|
9
|
+
module Backends
|
10
|
+
autoload :Null, 'exceptions/backends/null'
|
11
|
+
autoload :Raiser, 'exceptions/backends/raiser'
|
12
|
+
autoload :Multi, 'exceptions/backends/multi'
|
13
|
+
autoload :Logger, 'exceptions/backends/logger'
|
14
|
+
autoload :LogResult, 'exceptions/backends/log_result'
|
15
|
+
autoload :Honeybadger, 'exceptions/backends/honeybadger'
|
16
|
+
end
|
17
|
+
|
10
18
|
class << self
|
11
19
|
# Public: Forwards the exception to the configured backend.
|
12
20
|
#
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Exceptions::Backends::LogResult do
|
4
|
+
let(:logger) { double(::Logger) }
|
5
|
+
let(:backend) do
|
6
|
+
described_class.new \
|
7
|
+
double(Exceptions::Backend, notify: double(Exceptions::Result, ok?: true, id: '1234', url: 'http://exception.com')),
|
8
|
+
logger
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#notify' do
|
12
|
+
subject(:result) { backend.notify(boom) }
|
13
|
+
|
14
|
+
it 'logs the result' do
|
15
|
+
expect(logger).to receive(:info).with("at=exception exception=StandardError message=\"Boom\" exception-id=1234 url=http://exception.com source= count#exception=1")
|
16
|
+
result
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exceptions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric J. Holmes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,30 +42,30 @@ dependencies:
|
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 3.1.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 3.1.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: honeybadger
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.9.5
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 1.9.5
|
69
69
|
description: Exceptions is a Ruby gem for exception tracking.
|
70
70
|
email:
|
71
71
|
- eric@ejholmes.net
|
@@ -77,14 +77,14 @@ files:
|
|
77
77
|
- .rspec
|
78
78
|
- .travis.yml
|
79
79
|
- Gemfile
|
80
|
-
- LICENSE
|
80
|
+
- LICENSE
|
81
81
|
- README.md
|
82
82
|
- Rakefile
|
83
83
|
- exceptions.gemspec
|
84
84
|
- lib/exceptions.rb
|
85
85
|
- lib/exceptions/backend.rb
|
86
|
-
- lib/exceptions/backends.rb
|
87
86
|
- lib/exceptions/backends/honeybadger.rb
|
87
|
+
- lib/exceptions/backends/log_result.rb
|
88
88
|
- lib/exceptions/backends/logger.rb
|
89
89
|
- lib/exceptions/backends/multi.rb
|
90
90
|
- lib/exceptions/backends/null.rb
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- lib/rack/exceptions.rb
|
96
96
|
- spec/exceptions/backends/honeybadger/integration_spec.rb
|
97
97
|
- spec/exceptions/backends/honeybadger_spec.rb
|
98
|
+
- spec/exceptions/backends/log_result_spec.rb
|
98
99
|
- spec/exceptions/backends/logger/integration_spec.rb
|
99
100
|
- spec/exceptions/backends/multi_spec.rb
|
100
101
|
- spec/rack/exceptions_spec.rb
|
@@ -127,6 +128,7 @@ summary: Exceptions is a Ruby gem for exception tracking.
|
|
127
128
|
test_files:
|
128
129
|
- spec/exceptions/backends/honeybadger/integration_spec.rb
|
129
130
|
- spec/exceptions/backends/honeybadger_spec.rb
|
131
|
+
- spec/exceptions/backends/log_result_spec.rb
|
130
132
|
- spec/exceptions/backends/logger/integration_spec.rb
|
131
133
|
- spec/exceptions/backends/multi_spec.rb
|
132
134
|
- spec/rack/exceptions_spec.rb
|
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2014 Eric J. Holmes
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/exceptions/backends.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
module Exceptions
|
2
|
-
module Backends
|
3
|
-
autoload :Null, 'exceptions/backends/null'
|
4
|
-
autoload :Raiser, 'exceptions/backends/raiser'
|
5
|
-
autoload :Multi, 'exceptions/backends/multi'
|
6
|
-
autoload :Logger, 'exceptions/backends/logger'
|
7
|
-
autoload :Honeybadger, 'exceptions/backends/honeybadger'
|
8
|
-
end
|
9
|
-
end
|