multiple_devices_logger 3.0.1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.mdown +6 -0
- data/VERSION +1 -1
- data/lib/multiple_devices_logger/ignore_exceptions.rb +17 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19415b2e0ea7cb895f6b6fd64c56f32f318ee830
|
4
|
+
data.tar.gz: 1b9e00b61d944926836be3b48ade2cea0fca0c56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7c48a83c54d635bfb61ed4b79e406420225f369d240379af2b23cae1d34c9ab417b80a25292b8e8c71aacd434d111706cc1695f785e4f1d9236631e64e7e221
|
7
|
+
data.tar.gz: 4f2982efb97ce01c87b089aee3d59f2da66f4753f88e049f24f4d2096d5ca165cc56934763c0f8262e1cf5d73fc9989437a7b963775f4346d04b3358c2bdc9fc
|
data/README.mdown
CHANGED
@@ -94,6 +94,12 @@ the device:
|
|
94
94
|
logger.add_device(STDERR, :debug, ignore_exceptions: [IOError, ArgumentError])
|
95
95
|
```
|
96
96
|
|
97
|
+
In addition to classes, A lambda can be given to ignore exception, example:
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
logger.ignore_exceptions(ArgumentError, -> (e) { e.message =~ /404/ }
|
101
|
+
```
|
102
|
+
|
97
103
|
## Executing test suite
|
98
104
|
|
99
105
|
This project is fully tested with [Rspec 3](http://github.com/rspec/rspec).
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0
|
1
|
+
3.1.0
|
@@ -5,17 +5,22 @@ class MultipleDevicesLogger
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
def exception_ignored?(exception)
|
8
|
-
exception.is_a?(Exception)
|
9
|
-
|
10
|
-
end
|
8
|
+
return false unless exception.is_a?(Exception)
|
9
|
+
ignored_exception_classes.any? { |klass| exception.is_a?(klass) } || ignored_exceptions_procs.any? { |proc| proc.call(exception) }
|
11
10
|
end
|
12
11
|
|
13
|
-
def ignore_exceptions(*
|
12
|
+
def ignore_exceptions(*arguments, &block)
|
14
13
|
@ignored_exception_class_names ||= []
|
15
|
-
[
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
@ignored_exceptions_procs ||= []
|
15
|
+
@ignored_exceptions_procs << Proc.new(&block) if block_given?
|
16
|
+
[arguments].flatten.each do |argument|
|
17
|
+
if argument.respond_to?(:call)
|
18
|
+
@ignored_exceptions_procs << argument
|
19
|
+
else
|
20
|
+
klass = argument.is_a?(Class) ? argument : argument.to_s.presence.try(:constantize)
|
21
|
+
raise("Invalid exception class: #{argument.inspect}") unless klass.is_a?(Class) && (klass == Exception || (klass < Exception))
|
22
|
+
@ignored_exception_class_names << klass.name
|
23
|
+
end
|
19
24
|
end
|
20
25
|
@ignored_exception_class_names.uniq!
|
21
26
|
nil
|
@@ -25,6 +30,10 @@ class MultipleDevicesLogger
|
|
25
30
|
(@ignored_exception_class_names || []).map(&:constantize)
|
26
31
|
end
|
27
32
|
|
33
|
+
def ignored_exceptions_procs
|
34
|
+
@ignored_exceptions_procs || []
|
35
|
+
end
|
36
|
+
|
28
37
|
end
|
29
38
|
|
30
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multiple_devices_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexis Toulotte
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|