logging 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee30a5922d46012d8fc4e14db5cc86ea7dce9c6a
4
- data.tar.gz: 7183a4f01f0dd1000ab86d05c8b40e605dbb4b10
3
+ metadata.gz: c4be0dd542e3eac91b3ad7f7895e7a0dbfdadd66
4
+ data.tar.gz: 960c2a5e039c3f455f29dd6bf4fe3a700957194b
5
5
  SHA512:
6
- metadata.gz: 377702172ae965d27c082acd60914e0f3420a0e0bdfc5d981ac3cfad7c8f3bf46095007511075b6a9db9225963911967d3d63989a3ee6dc42588269092796a72
7
- data.tar.gz: 1a6f33f20259879ca8cc9adcbd9a3bfb14c44f03a15311711f11ff4bf98edfd9821000e8b9afcb5401080a693e391bb83e56bd0055e1eedcbba6ce7ba4a92f2b
6
+ metadata.gz: ab8acc6f8f984c8533c667c73fffb4b6e5286d1a401af2989ca1d1e0a4beac3b2147abf9c87dcf52339e32da1be8b3db41d770acb9c38c40e84c07e50b3e9776
7
+ data.tar.gz: 2bdab15e9bfb48a5b3a30214bdaf375b2536dac54a334ee27ca8fafbda1ba6068a6a0aff1a91524eadd10d22525a5607eb41eacf3fc8e8d69402b08fd5ec73df
@@ -8,7 +8,7 @@ script: "rake"
8
8
  rvm:
9
9
  - 2.0.0-p648
10
10
  - 2.1.10
11
- - 2.2.6
12
- - 2.3.3
13
- - 2.4.0
11
+ - 2.2.7
12
+ - 2.3.4
13
+ - 2.4.1
14
14
  - jruby-9.1.8.0
@@ -1,3 +1,8 @@
1
+ == 2.2.1 / 2017-04-09
2
+
3
+ Enhancements
4
+ - show exception `cause` if one exists [PR #165]
5
+
1
6
  == 2.2.0 / 2017-03-09
2
7
 
3
8
  Enhancements
@@ -142,11 +142,15 @@ class Layout
142
142
  case obj
143
143
  when String; obj
144
144
  when Exception
145
- str = "<#{obj.class.name}> #{obj.message}"
145
+ ary = ["<#{obj.class.name}> #{obj.message}"]
146
146
  if backtrace? && !obj.backtrace.nil?
147
- str << "\n\t" << obj.backtrace.join("\n\t")
147
+ ary.concat(obj.backtrace)
148
148
  end
149
- str
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 @backtrace && !obj.backtrace.nil?
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)
@@ -1,5 +1,5 @@
1
1
  module Logging
2
- VERSION = "2.2.0".freeze
2
+ VERSION = "2.2.1".freeze
3
3
 
4
4
  # Returns the version string for the library.
5
5
  def self.version
@@ -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.0
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-03-10 00:00:00.000000000 Z
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.8
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