logging 2.2.0 → 2.2.1
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/.travis.yml +3 -3
- data/History.txt +5 -0
- data/lib/logging/layout.rb +7 -3
- data/lib/logging/layouts/parseable.rb +2 -1
- data/lib/logging/version.rb +1 -1
- data/test/layouts/test_nested_exceptions.rb +52 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4be0dd542e3eac91b3ad7f7895e7a0dbfdadd66
|
4
|
+
data.tar.gz: 960c2a5e039c3f455f29dd6bf4fe3a700957194b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab8acc6f8f984c8533c667c73fffb4b6e5286d1a401af2989ca1d1e0a4beac3b2147abf9c87dcf52339e32da1be8b3db41d770acb9c38c40e84c07e50b3e9776
|
7
|
+
data.tar.gz: 2bdab15e9bfb48a5b3a30214bdaf375b2536dac54a334ee27ca8fafbda1ba6068a6a0aff1a91524eadd10d22525a5607eb41eacf3fc8e8d69402b08fd5ec73df
|
data/.travis.yml
CHANGED
data/History.txt
CHANGED
data/lib/logging/layout.rb
CHANGED
@@ -142,11 +142,15 @@ class Layout
|
|
142
142
|
case obj
|
143
143
|
when String; obj
|
144
144
|
when Exception
|
145
|
-
|
145
|
+
ary = ["<#{obj.class.name}> #{obj.message}"]
|
146
146
|
if backtrace? && !obj.backtrace.nil?
|
147
|
-
|
147
|
+
ary.concat(obj.backtrace)
|
148
148
|
end
|
149
|
-
|
149
|
+
if defined?(obj.cause) && !obj.cause.nil?
|
150
|
+
ary << "--- Caused by ---"
|
151
|
+
ary << format_obj(obj.cause)
|
152
|
+
end
|
153
|
+
ary.join("\n\t")
|
150
154
|
when nil; "<#{obj.class.name}> nil"
|
151
155
|
else
|
152
156
|
str = "<#{obj.class.name}> "
|
@@ -221,7 +221,8 @@ module Logging::Layouts
|
|
221
221
|
when Exception
|
222
222
|
h = { :class => obj.class.name,
|
223
223
|
:message => obj.message }
|
224
|
-
h[:backtrace] = obj.backtrace if
|
224
|
+
h[:backtrace] = obj.backtrace if backtrace? && !obj.backtrace.nil?
|
225
|
+
h[:cause] = format_obj(obj.cause) if defined?(obj.cause) && !obj.cause.nil?
|
225
226
|
h
|
226
227
|
when Time
|
227
228
|
iso8601_format(obj)
|
data/lib/logging/version.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
require_relative '../setup'
|
3
|
+
|
4
|
+
module TestLogging
|
5
|
+
module TestLayouts
|
6
|
+
class TestNestedExceptions < Test::Unit::TestCase
|
7
|
+
include LoggingTestCase
|
8
|
+
|
9
|
+
def test_basic_format_obj
|
10
|
+
begin
|
11
|
+
raise StandardError, 'nested exception'
|
12
|
+
rescue
|
13
|
+
raise Exception, 'root exception'
|
14
|
+
end
|
15
|
+
rescue Exception => e
|
16
|
+
layout = Logging.layouts.basic({})
|
17
|
+
log = layout.format_obj(e)
|
18
|
+
assert_not_nil log.index('<Exception> root exception')
|
19
|
+
|
20
|
+
if defined? e.cause
|
21
|
+
assert_not_nil log.index('<StandardError> nested exception')
|
22
|
+
assert_operator log.index('<Exception> root exception'), :<, log.index('<StandardError> nested exception')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_parseable_format_obj
|
27
|
+
begin
|
28
|
+
raise StandardError, 'nested exception'
|
29
|
+
rescue
|
30
|
+
raise Exception, 'root exception'
|
31
|
+
end
|
32
|
+
rescue Exception => e
|
33
|
+
layout = Logging.layouts.parseable.new
|
34
|
+
log = layout.format_obj(e)
|
35
|
+
assert_equal Exception.name, log[:class]
|
36
|
+
assert_equal 'root exception', log[:message]
|
37
|
+
assert_operator log[:backtrace].size, :>, 0
|
38
|
+
|
39
|
+
if defined? e.cause
|
40
|
+
assert_not_nil log[:cause]
|
41
|
+
|
42
|
+
log = log[:cause]
|
43
|
+
assert_equal StandardError.name, log[:class]
|
44
|
+
assert_equal 'nested exception', log[:message]
|
45
|
+
assert_nil log[:cause]
|
46
|
+
assert_operator log[:backtrace].size, :>, 0
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Pease
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: little-plugger
|
@@ -158,6 +158,7 @@ files:
|
|
158
158
|
- test/layouts/test_basic.rb
|
159
159
|
- test/layouts/test_color_pattern.rb
|
160
160
|
- test/layouts/test_json.rb
|
161
|
+
- test/layouts/test_nested_exceptions.rb
|
161
162
|
- test/layouts/test_pattern.rb
|
162
163
|
- test/layouts/test_yaml.rb
|
163
164
|
- test/performance.rb
|
@@ -196,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
197
|
version: '0'
|
197
198
|
requirements: []
|
198
199
|
rubyforge_project: logging
|
199
|
-
rubygems_version: 2.6.
|
200
|
+
rubygems_version: 2.6.11
|
200
201
|
signing_key:
|
201
202
|
specification_version: 4
|
202
203
|
summary: A flexible and extendable logging library for Ruby
|
@@ -212,6 +213,7 @@ test_files:
|
|
212
213
|
- test/layouts/test_basic.rb
|
213
214
|
- test/layouts/test_color_pattern.rb
|
214
215
|
- test/layouts/test_json.rb
|
216
|
+
- test/layouts/test_nested_exceptions.rb
|
215
217
|
- test/layouts/test_pattern.rb
|
216
218
|
- test/layouts/test_yaml.rb
|
217
219
|
- test/test_appender.rb
|