logging 2.2.2 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -105,7 +105,7 @@ module TestLayouts
105
105
  'log message', false)
106
106
  event.file = 'test_file.rb'
107
107
  event.line = '123'
108
- event.method = 'method_name'
108
+ event.method_name = 'method_name'
109
109
 
110
110
  @layout.pattern = '%c'
111
111
  assert_equal 'TestLogger', @layout.format(event)
@@ -68,7 +68,7 @@ module TestLayouts
68
68
  'log message', false)
69
69
  event.file = 'test_file.rb'
70
70
  event.line = 123
71
- event.method = 'method_name'
71
+ event.method_name = 'method_name'
72
72
 
73
73
  @layout.items = %w[logger]
74
74
  assert_match %r/\A--- ?\nlogger: TestLogger\n/, @layout.format(event)
data/test/setup.rb CHANGED
@@ -5,6 +5,12 @@ LOGGING_TEST_SETUP = true
5
5
 
6
6
  require "rubygems"
7
7
  require "test/unit"
8
+ require "tmpdir"
9
+
10
+ LOGGING_TEST_TMPDIR = Dir.mktmpdir("logging")
11
+ Test::Unit.at_exit do
12
+ FileUtils.remove_entry(LOGGING_TEST_TMPDIR)
13
+ end
8
14
 
9
15
  if Test::Unit::TestCase.respond_to? :test_order=
10
16
  Test::Unit::TestCase.test_order = :random
@@ -15,18 +21,16 @@ require File.expand_path("../../lib/logging", __FILE__)
15
21
  module TestLogging
16
22
  module LoggingTestCase
17
23
 
18
- TMP = 'tmp'
19
-
20
24
  def setup
21
25
  super
22
26
  Logging.reset
23
- FileUtils.rm_rf TMP
24
- FileUtils.mkdir TMP
27
+ @tmpdir = LOGGING_TEST_TMPDIR
28
+ FileUtils.rm_rf(Dir.glob(File.join(@tmpdir, "*")))
25
29
  end
26
30
 
27
31
  def teardown
28
32
  super
29
- FileUtils.rm_rf TMP
33
+ FileUtils.rm_rf(Dir.glob(File.join(@tmpdir, "*")))
30
34
  end
31
35
  end
32
36
  end
@@ -68,12 +68,12 @@ module TestLogging
68
68
  assert_equal 'MyLogger', @event.logger
69
69
  end
70
70
 
71
- def test_method
71
+ def test_method_name
72
72
  assert_equal '', @event.file
73
73
 
74
74
  @logger.caller_tracing = true
75
75
  @logger.debug 'debug message'
76
- assert_equal 'test_method', @appender.event.method
76
+ assert_equal 'test_method_name', @appender.event.method_name
77
77
  end
78
78
 
79
79
  end # class TestLogEvent
data/test/test_logging.rb CHANGED
@@ -11,8 +11,8 @@ module TestLogging
11
11
  @levels = ::Logging::LEVELS
12
12
  @lnames = ::Logging::LNAMES
13
13
 
14
- @fn = File.join(TMP, 'test.log')
15
- @glob = File.join(TMP, '*.log')
14
+ @fn = File.join(@tmpdir, 'test.log')
15
+ @glob = File.join(@tmpdir, '*.log')
16
16
  end
17
17
 
18
18
  def test_backtrace
@@ -253,6 +253,31 @@ module TestLogging
253
253
  assert_match %r/\d+\.\d+\.\d+/, ::Logging.version
254
254
  end
255
255
 
256
- end # class TestLogging
257
- end # module TestLogging
256
+ class Failer
257
+ class WriteError < StandardError ; end
258
+ def self.write(*args)
259
+ raise WriteError.new("Oh noooooo")
260
+ end
261
+ end
258
262
 
263
+ def test_error_handling
264
+ logger = ::Logging.logger Failer, 2, 100
265
+ logger.appenders.first.level = :debug
266
+
267
+ # No errors are raised by default
268
+ logger.fatal 'this is a debug message'
269
+ # Always reset the level; we disable appenders that raise by setting them
270
+ # to :off
271
+ logger.appenders.first.level = :debug
272
+
273
+ begin
274
+ Logging.raise_errors = true
275
+ assert_raises Failer::WriteError do
276
+ logger.fatal 'this fails because the file descriptor is closed'
277
+ end
278
+ ensure
279
+ Logging.raise_errors = false
280
+ end
281
+ end
282
+ end
283
+ end
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.2
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Pease
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-11 00:00:00.000000000 Z
11
+ date: 2022-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: little-plugger
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.10'
33
+ version: '1.14'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.10'
40
+ version: '1.14'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: test-unit
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.1'
47
+ version: '3.3'
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: '3.1'
54
+ version: '3.3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bones-git
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 3.8.4
75
+ version: 3.8.5
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 3.8.4
82
+ version: 3.8.5
83
83
  description: |-
84
84
  **Logging** is a flexible logging library for use in Ruby programs based on the
85
85
  design of Java's log4j library. It features a hierarchical logging system,
@@ -179,7 +179,7 @@ files:
179
179
  homepage: http://rubygems.org/gems/logging
180
180
  licenses: []
181
181
  metadata: {}
182
- post_install_message:
182
+ post_install_message:
183
183
  rdoc_options:
184
184
  - "--main"
185
185
  - README.md
@@ -196,9 +196,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  - !ruby/object:Gem::Version
197
197
  version: '0'
198
198
  requirements: []
199
- rubyforge_project: logging
200
- rubygems_version: 2.6.11
201
- signing_key:
199
+ rubygems_version: 3.3.7
200
+ signing_key:
202
201
  specification_version: 4
203
202
  summary: A flexible and extendable logging library for Ruby
204
203
  test_files: