logging 2.3.0 → 2.3.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
  SHA256:
3
- metadata.gz: 1ec479cf977c621a6b42426cfe7c478a97e106c23762f3608ee67fcbaa49b324
4
- data.tar.gz: 6a0c0107cf3c1a1f7504e19e85a9505ad94c4a84991d01eb6c65191257a01163
3
+ metadata.gz: f7bb89dcc5956ebabbf591d8f8d348e0e3cfdc7cb5fa356e9995168278b45a95
4
+ data.tar.gz: be4ad44cf88417be5abe80fbaf0b1d28a2f4899df2c00d1d4818af78cc440443
5
5
  SHA512:
6
- metadata.gz: 2cd72dabcd8b878b73f69ec8a445678b14635ca1c115576ef148a7160673f83939d7706e5d673c32ed11ef2c48046cc7a50bd2c2c0795b2fa79c35e9d4bccf87
7
- data.tar.gz: 23422872b58d1bd0e0a146f64e4bb792ef5208da309b16e7650d5c74ca9969b12e6e65dd5ef79a90ce39e0d6c51dbc7514f7a2e913ec74b2e8404a06aefa8975
6
+ metadata.gz: b61a6a3bcda67484ec4334a89adfd6149d2aa91be51ba0ca476514c7c4532d0b4040cc202ce58d30e9d93ba5821e6eedbde77d8bdeaac7a82224731796d79eda
7
+ data.tar.gz: 55c888af479f8c01eb89f96eda24b2cc9cd92f52cc0b1f21d5fde7fcb7e91e573b6007998c67b00781cf8c5ea3eadcb9462b9df2da26dbcfe0464deb13340d18
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 2.3.1 / 2022-05-24
2
+
3
+ Bug Fixes
4
+ - logging hangs on JRuby when the stdout appender is closed [PR #237]
5
+ - initialize the Logging framework when a Filter is created [PR #238]
6
+
1
7
  == 2.3.0 / 2020-07-04
2
8
 
3
9
  Enhancements
@@ -37,10 +37,7 @@ module Logging::Appenders
37
37
  # is currently open then it will be closed and immediately reopened.
38
38
  def reopen
39
39
  @mutex.synchronize {
40
- if defined? @io && @io
41
- flush
42
- @io.close rescue nil
43
- end
40
+ flush if defined? @io && @io
44
41
  @io = open_fd
45
42
  }
46
43
  super
@@ -51,20 +48,13 @@ module Logging::Appenders
51
48
 
52
49
  def open_fd
53
50
  case self.class.name
54
- when "Logging::Appenders::Stdout"
55
- fd = STDOUT.fileno
56
- encoding = STDOUT.external_encoding
57
- when "Logging::Appenders::Stderr"
58
- fd = STDERR.fileno
59
- encoding = STDERR.external_encoding
51
+ when "Logging::Appenders::Stdout"; STDOUT
52
+ when "Logging::Appenders::Stderr"; STDERR
60
53
  else
61
54
  raise RuntimeError, "Please do not use the `Logging::Appenders::Console` class directly - " +
62
55
  "use `Logging::Appenders::Stdout` and `Logging::Appenders::Stderr` instead" +
63
56
  " [class #{self.class.name}]"
64
57
  end
65
-
66
- mode = ::File::WRONLY | ::File::APPEND
67
- ::IO.for_fd(fd, mode: mode, encoding: encoding)
68
58
  end
69
59
  end
70
60
 
@@ -48,7 +48,7 @@ module Logging::Appenders
48
48
  super
49
49
 
50
50
  io, @io = @io, nil
51
- unless [STDIN, STDERR, STDOUT].include?(io)
51
+ if ![STDIN, STDERR, STDOUT].include?(io)
52
52
  io.send(@close_method) if @close_method && io.respond_to?(@close_method)
53
53
  end
54
54
  rescue IOError
@@ -8,10 +8,17 @@ module Logging
8
8
  # Otherwise the `allow` method should return `nil`.
9
9
  class Filter
10
10
 
11
- # Returns the event if it should be allowed into the log. Returns `nil` if
12
- # the event should _not_ be allowed into the log. Subclasses should override
13
- # this method and provide their own filtering semantics.
14
- def allow( event )
11
+ # Creates a new level filter that will pass all log events. Create a
12
+ # subclass and override the `allow` method to filter log events.
13
+ def initialize
14
+ ::Logging.init unless ::Logging.initialized?
15
+ end
16
+
17
+ # Returns the event if it should be forwarded to the logging appender.
18
+ # Returns `nil` if the event should _not_ be forwarded to the logging
19
+ # appender. Subclasses should override this method and provide their own
20
+ # filtering semantics.
21
+ def allow(event)
15
22
  event
16
23
  end
17
24
  end
@@ -4,8 +4,7 @@ module Logging
4
4
  module Filters
5
5
 
6
6
  # The `Level` filter class provides a simple level-based filtering mechanism
7
- # that filters messages to only include those from an enumerated list of
8
- # levels to log.
7
+ # that allows events whose log level matches a preconfigured list of values.
9
8
  class Level < ::Logging::Filter
10
9
 
11
10
  # Creates a new level filter that will only allow the given _levels_ to
@@ -15,15 +14,19 @@ module Logging
15
14
  # Examples
16
15
  # Logging::Filters::Level.new(:debug, :info)
17
16
  #
18
- def initialize( *levels )
19
- levels = levels.map { |level| ::Logging::level_num(level) }
20
- @levels = Set.new levels
17
+ def initialize(*levels)
18
+ super()
19
+ levels = levels.flatten.map {|level| ::Logging::level_num(level)}
20
+ @levels = Set.new(levels)
21
21
  end
22
22
 
23
- def allow( event )
23
+ # Returns the event if it should be forwarded to the logging appender.
24
+ # Otherwise, `nil` is returned. The log event is allowed if the
25
+ # `event.level` matches one of the levels provided to the filter when it
26
+ # was constructred.
27
+ def allow(event)
24
28
  @levels.include?(event.level) ? event : nil
25
29
  end
26
-
27
30
  end
28
31
  end
29
32
  end
@@ -1,4 +1,4 @@
1
1
  module Logging
2
2
  module Filters ; end
3
3
  require libpath('logging/filters/level')
4
- end
4
+ end
@@ -12,7 +12,8 @@ module Logging
12
12
  # * $3 == method name (might be nil)
13
13
  CALLER_RGXP = %r/([-\.\/\(\)\w]+):(\d+)(?::in `([^']+)')?/o
14
14
  #CALLER_INDEX = 2
15
- CALLER_INDEX = ((defined? JRUBY_VERSION and JRUBY_VERSION > '1.6') or (defined? RUBY_ENGINE and RUBY_ENGINE[%r/^rbx/i])) ? 1 : 2
15
+ CALLER_INDEX = ((defined?(JRUBY_VERSION) && JRUBY_VERSION > '1.6' && JRUBY_VERSION < '9.0') ||
16
+ (defined?(RUBY_ENGINE) && RUBY_ENGINE[%r/^rbx/i])) ? 1 : 2
16
17
  # :startdoc:
17
18
 
18
19
  attr_accessor :logger, :level, :data, :time, :file, :line, :method_name
@@ -1,5 +1,5 @@
1
1
  module Logging
2
- VERSION = "2.3.0".freeze
2
+ VERSION = "2.3.1".freeze
3
3
 
4
4
  # Returns the version string for the library.
5
5
  def self.version
@@ -22,7 +22,7 @@ module TestAppenders
22
22
  assert_equal 'stdout', appender.name
23
23
 
24
24
  io = appender.instance_variable_get(:@io)
25
- refute_same STDOUT, io
25
+ assert_same STDOUT, io
26
26
  assert_equal STDOUT.fileno, io.fileno
27
27
 
28
28
  appender = Logging.appenders.stdout('foo')
@@ -45,16 +45,16 @@ module TestAppenders
45
45
 
46
46
  appender.close
47
47
  assert appender.closed?
48
- assert io.closed?
48
+ refute io.closed?
49
49
  refute STDOUT.closed?
50
50
 
51
51
  appender.reopen
52
52
  refute appender.closed?
53
53
 
54
54
  new_io = appender.instance_variable_get(:@io)
55
- refute_same io, new_io
55
+ assert_same io, new_io
56
56
  refute new_io.closed?
57
- assert io.closed?
57
+ refute io.closed?
58
58
  end
59
59
  end
60
60
 
@@ -68,8 +68,8 @@ module TestAppenders
68
68
  assert_equal 'stderr', appender.name
69
69
 
70
70
  io = appender.instance_variable_get(:@io)
71
- refute_same STDERR, io
72
- assert_same STDERR.fileno, io.fileno
71
+ assert_same STDERR, io
72
+ assert_equal STDERR.fileno, io.fileno
73
73
 
74
74
  appender = Logging.appenders.stderr('foo')
75
75
  assert_equal 'foo', appender.name
@@ -91,16 +91,16 @@ module TestAppenders
91
91
 
92
92
  appender.close
93
93
  assert appender.closed?
94
- assert io.closed?
94
+ refute io.closed?
95
95
  refute STDERR.closed?
96
96
 
97
97
  appender.reopen
98
98
  refute appender.closed?
99
99
 
100
100
  new_io = appender.instance_variable_get(:@io)
101
- refute_same io, new_io
101
+ assert_same io, new_io
102
102
  refute new_io.closed?
103
- assert io.closed?
103
+ refute io.closed?
104
104
  end
105
105
  end
106
106
  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.3.0
4
+ version: 2.3.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: 2020-07-04 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
@@ -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,
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  - !ruby/object:Gem::Version
197
197
  version: '0'
198
198
  requirements: []
199
- rubygems_version: 3.0.1
199
+ rubygems_version: 3.3.7
200
200
  signing_key:
201
201
  specification_version: 4
202
202
  summary: A flexible and extendable logging library for Ruby