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 +4 -4
- data/History.txt +6 -0
- data/lib/logging/appenders/console.rb +3 -13
- data/lib/logging/appenders/io.rb +1 -1
- data/lib/logging/filter.rb +11 -4
- data/lib/logging/filters/level.rb +10 -7
- data/lib/logging/filters.rb +1 -1
- data/lib/logging/log_event.rb +2 -1
- data/lib/logging/version.rb +1 -1
- data/test/appenders/test_console.rb +9 -9
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7bb89dcc5956ebabbf591d8f8d348e0e3cfdc7cb5fa356e9995168278b45a95
|
4
|
+
data.tar.gz: be4ad44cf88417be5abe80fbaf0b1d28a2f4899df2c00d1d4818af78cc440443
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b61a6a3bcda67484ec4334a89adfd6149d2aa91be51ba0ca476514c7c4532d0b4040cc202ce58d30e9d93ba5821e6eedbde77d8bdeaac7a82224731796d79eda
|
7
|
+
data.tar.gz: 55c888af479f8c01eb89f96eda24b2cc9cd92f52cc0b1f21d5fde7fcb7e91e573b6007998c67b00781cf8c5ea3eadcb9462b9df2da26dbcfe0464deb13340d18
|
data/History.txt
CHANGED
@@ -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
|
-
|
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
|
|
data/lib/logging/appenders/io.rb
CHANGED
data/lib/logging/filter.rb
CHANGED
@@ -8,10 +8,17 @@ module Logging
|
|
8
8
|
# Otherwise the `allow` method should return `nil`.
|
9
9
|
class Filter
|
10
10
|
|
11
|
-
#
|
12
|
-
#
|
13
|
-
|
14
|
-
|
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
|
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(
|
19
|
-
|
20
|
-
|
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
|
-
|
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
|
data/lib/logging/filters.rb
CHANGED
data/lib/logging/log_event.rb
CHANGED
@@ -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?
|
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
|
data/lib/logging/version.rb
CHANGED
@@ -22,7 +22,7 @@ module TestAppenders
|
|
22
22
|
assert_equal 'stdout', appender.name
|
23
23
|
|
24
24
|
io = appender.instance_variable_get(:@io)
|
25
|
-
|
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
|
-
|
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
|
-
|
55
|
+
assert_same io, new_io
|
56
56
|
refute new_io.closed?
|
57
|
-
|
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
|
-
|
72
|
-
|
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
|
-
|
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
|
-
|
101
|
+
assert_same io, new_io
|
102
102
|
refute new_io.closed?
|
103
|
-
|
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.
|
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:
|
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.
|
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.
|
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.
|
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
|