console 1.25.1 → 1.26.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/console/capture.rb +36 -16
- data/lib/console/filter.rb +9 -4
- data/lib/console/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea53f121a472d6011335a91ac4a96f4f3630c4524b1158166be906a51e4dd186
|
4
|
+
data.tar.gz: 20cdb45a16606315c9a0e054fb9e3460698e6fcccd190bd7668902f179c7b5fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42748b35f41a887222716d8bd0b9e55f92a5506f31fa7cb0a3e5ac5155341c55d6ca2849745b77d568b7b11e3d79faf0193377b9547fce98c5c16ca1043f9222
|
7
|
+
data.tar.gz: de9535e3fb41fcce945512f9d482329cfc695888c43da753d1f7c392e074e4b4b1e6584fbfd1c39b4851c25f00563b1e0ee3efbd5240294649ff4dc68519483d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/console/capture.rb
CHANGED
@@ -9,27 +9,45 @@ module Console
|
|
9
9
|
# A general sink which captures all events into a buffer.
|
10
10
|
class Capture
|
11
11
|
def initialize
|
12
|
-
@
|
12
|
+
@records = []
|
13
13
|
@verbose = false
|
14
14
|
end
|
15
15
|
|
16
|
-
attr :
|
16
|
+
attr :records
|
17
|
+
|
18
|
+
# @deprecated Use {#records} instead of {#buffer}.
|
19
|
+
alias buffer records
|
20
|
+
|
21
|
+
alias to_a records
|
22
|
+
|
17
23
|
attr :verbose
|
18
24
|
|
19
|
-
def
|
20
|
-
@
|
25
|
+
def include?(pattern)
|
26
|
+
@records.any? do |record|
|
27
|
+
record[:subject].to_s&.match?(pattern) or record[:message].to_s&.match?(pattern)
|
28
|
+
end
|
21
29
|
end
|
22
30
|
|
23
|
-
def
|
24
|
-
|
31
|
+
def each(&block)
|
32
|
+
@records.each(&block)
|
33
|
+
end
|
34
|
+
|
35
|
+
include Enumerable
|
36
|
+
|
37
|
+
def first
|
38
|
+
@records.first
|
39
|
+
end
|
40
|
+
|
41
|
+
def last
|
42
|
+
@records.last
|
25
43
|
end
|
26
44
|
|
27
45
|
def clear
|
28
|
-
@
|
46
|
+
@records.clear
|
29
47
|
end
|
30
48
|
|
31
49
|
def empty?
|
32
|
-
@
|
50
|
+
@records.empty?
|
33
51
|
end
|
34
52
|
|
35
53
|
def verbose!(value = true)
|
@@ -41,39 +59,41 @@ module Console
|
|
41
59
|
end
|
42
60
|
|
43
61
|
def call(subject = nil, *arguments, severity: UNKNOWN, event: nil, **options, &block)
|
44
|
-
|
62
|
+
record = {
|
45
63
|
time: ::Time.now.iso8601,
|
46
64
|
severity: severity,
|
47
65
|
**options,
|
48
66
|
}
|
49
67
|
|
50
68
|
if subject
|
51
|
-
|
69
|
+
record[:subject] = subject
|
52
70
|
end
|
53
71
|
|
54
72
|
if event
|
55
|
-
|
73
|
+
record[:event] = event.to_hash
|
56
74
|
end
|
57
75
|
|
58
76
|
if arguments.any?
|
59
|
-
|
77
|
+
record[:arguments] = arguments
|
60
78
|
end
|
61
79
|
|
62
80
|
if annotation = Fiber.current.annotation
|
63
|
-
|
81
|
+
record[:annotation] = annotation
|
64
82
|
end
|
65
83
|
|
66
84
|
if block_given?
|
67
85
|
if block.arity.zero?
|
68
|
-
|
86
|
+
record[:message] = yield
|
69
87
|
else
|
70
88
|
buffer = StringIO.new
|
71
89
|
yield buffer
|
72
|
-
|
90
|
+
record[:message] = buffer.string
|
73
91
|
end
|
92
|
+
else
|
93
|
+
record[:message] = arguments.join(" ")
|
74
94
|
end
|
75
95
|
|
76
|
-
@
|
96
|
+
@records << record
|
77
97
|
end
|
78
98
|
end
|
79
99
|
end
|
data/lib/console/filter.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
# Copyright, 2021, by Robert Schulze.
|
8
8
|
|
9
9
|
module Console
|
10
|
-
UNKNOWN =
|
10
|
+
UNKNOWN = :unknown
|
11
11
|
|
12
12
|
class Filter
|
13
13
|
if Object.const_defined?(:Ractor) and RUBY_VERSION >= '3.1'
|
@@ -35,7 +35,7 @@ module Console
|
|
35
35
|
|
36
36
|
define_immutable_method(name) do |subject = nil, *arguments, **options, &block|
|
37
37
|
if self.enabled?(subject, level)
|
38
|
-
|
38
|
+
@output.call(subject, *arguments, severity: name, **@options, **options, &block)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -143,8 +143,13 @@ module Console
|
|
143
143
|
@subjects.delete(subject)
|
144
144
|
end
|
145
145
|
|
146
|
-
def call(*arguments, **options, &block)
|
147
|
-
|
146
|
+
def call(subject, *arguments, **options, &block)
|
147
|
+
severity = options[:severity] || UNKNOWN
|
148
|
+
level = self.class::LEVELS[severity]
|
149
|
+
|
150
|
+
if self.enabled?(subject, level)
|
151
|
+
@output.call(subject, *arguments, **options, &block)
|
152
|
+
end
|
148
153
|
end
|
149
154
|
end
|
150
155
|
end
|
data/lib/console/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: console
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.26.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -46,7 +46,7 @@ cert_chain:
|
|
46
46
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
47
47
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
48
48
|
-----END CERTIFICATE-----
|
49
|
-
date: 2024-
|
49
|
+
date: 2024-07-17 00:00:00.000000000 Z
|
50
50
|
dependencies:
|
51
51
|
- !ruby/object:Gem::Dependency
|
52
52
|
name: fiber-annotation
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
- !ruby/object:Gem::Version
|
150
150
|
version: '0'
|
151
151
|
requirements: []
|
152
|
-
rubygems_version: 3.5.
|
152
|
+
rubygems_version: 3.5.11
|
153
153
|
signing_key:
|
154
154
|
specification_version: 4
|
155
155
|
summary: Beautiful logging for Ruby.
|
metadata.gz.sig
CHANGED
Binary file
|