console 1.34.0 → 1.34.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -6
- data/lib/console/compatible/logger.rb +1 -0
- data/lib/console/filter.rb +10 -1
- data/lib/console/format/safe.rb +34 -42
- data/lib/console/output/serialized.rb +5 -2
- data/lib/console/version.rb +1 -1
- data/license.md +1 -0
- data/readme.md +5 -0
- data/releases.md +9 -4
- data.tar.gz.sig +0 -0
- metadata +3 -2
- 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: b7e414a46e5716a01454dd3de08d555a2532b0e44410a79aa69c1087d532c8a8
|
|
4
|
+
data.tar.gz: e816f35382d5e52ac66573dfa22fa862a2ee058eac5d5a0226cbc13c6a4bd8af
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6372b6d01aa3246fa609a46ce66c7c73051ea629f7975f2d26e5a22709d5f73d8f9962cd9cdd7f6431faa3e4a4f5287db1938df6327ed834d9d6aab7d111b6a2
|
|
7
|
+
data.tar.gz: 1f99ff50e204fef43b73b54bc0fc19861b51d797b62ebcd136065189632e6365a4fa2115a6cb155e3947aad250d728f6a5d5987e63ad583f677ab67042bdc83b
|
checksums.yaml.gz.sig
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
�
|
|
3
|
-
�����$~�9n譴��]�������_��p}t�aKь6��5-#�9�z��(3T瘉�.���v5@����C���=p&�,=�+U�
|
|
4
|
-
l]��>���`�<}���4BU����
|
|
5
|
-
qY�,o��G�;i�}�;R�K�l�gӱ"�<.����%�(F{�>6�4�2ŷ���
|
|
6
|
-
�-���-��gm�D�����3���;��s�
|
|
1
|
+
��S�"��uE�v����)�s��`'������6��_ކY������ç�F3�MVo>dzx@�3Za�;!Ç'���Ƶ��𩉑}�P
|
|
2
|
+
b6�xρ�\O�S���������F �a<k���Φ��gߜp�bz%�ړ���<h�<���w�.ql�͓He�b�ۆ�6��Cw���y���S5k��麗�]����%G��4�M܀�5r!eiS�ʮ�+��wk��n��?x�Qik��Ц9�;�~X�6J��2��2�V`�<�h�hа|0��J[w�>����|�:[\<w�ܧ�ӰXʸ�������c�F�~D-�f\��@��_�c/�$wp��cN�x�b�XǸ�F����܄Ĺ#��.C:&
|
data/lib/console/filter.rb
CHANGED
|
@@ -40,6 +40,10 @@ module Console
|
|
|
40
40
|
const_set(:MINIMUM_LEVEL, minimum_level)
|
|
41
41
|
const_set(:MAXIMUM_LEVEL, maximum_level)
|
|
42
42
|
|
|
43
|
+
# The default log level for instances of this filter class.
|
|
44
|
+
# Set to MINIMUM_LEVEL to allow all messages by default.
|
|
45
|
+
const_set(:DEFAULT_LEVEL, minimum_level)
|
|
46
|
+
|
|
43
47
|
levels.each do |name, level|
|
|
44
48
|
const_set(name.to_s.upcase, level)
|
|
45
49
|
|
|
@@ -206,6 +210,10 @@ module Console
|
|
|
206
210
|
|
|
207
211
|
# Log a message with the given severity.
|
|
208
212
|
#
|
|
213
|
+
# If the severity is not defined in this filter's LEVELS (e.g., when chaining
|
|
214
|
+
# filters with different severity levels), the message is passed through to the
|
|
215
|
+
# output without filtering. This allows custom filters to be composed together.
|
|
216
|
+
#
|
|
209
217
|
# @parameter subject [Object] The subject of the log message.
|
|
210
218
|
# @parameter arguments [Array] The arguments to log.
|
|
211
219
|
# @parameter options [Hash] Additional options to pass to the output.
|
|
@@ -215,7 +223,8 @@ module Console
|
|
|
215
223
|
severity = options[:severity] || UNKNOWN
|
|
216
224
|
level = self.class::LEVELS[severity]
|
|
217
225
|
|
|
218
|
-
|
|
226
|
+
# If the severity is unknown (level is nil), pass through to output without filtering:
|
|
227
|
+
if level.nil? || self.enabled?(subject, level)
|
|
219
228
|
@output.call(subject, *arguments, **options, &block)
|
|
220
229
|
end
|
|
221
230
|
|
data/lib/console/format/safe.rb
CHANGED
|
@@ -17,7 +17,7 @@ module Console
|
|
|
17
17
|
# @parameter format [JSON] The format to use for serialization.
|
|
18
18
|
# @parameter limit [Integer] The maximum depth to recurse into objects.
|
|
19
19
|
# @parameter encoding [Encoding] The encoding to use for strings.
|
|
20
|
-
def initialize(format: ::JSON, limit:
|
|
20
|
+
def initialize(format: ::JSON, limit: 12, encoding: ::Encoding::UTF_8)
|
|
21
21
|
@format = format
|
|
22
22
|
@limit = limit
|
|
23
23
|
@encoding = encoding
|
|
@@ -96,21 +96,6 @@ module Console
|
|
|
96
96
|
return object
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
-
# Replace the given object with a safe truncated representation.
|
|
100
|
-
#
|
|
101
|
-
# @parameter object [Object] The object to replace.
|
|
102
|
-
# @returns [String] The replacement string.
|
|
103
|
-
def replacement_for(object)
|
|
104
|
-
case object
|
|
105
|
-
when Array
|
|
106
|
-
"[...]"
|
|
107
|
-
when Hash
|
|
108
|
-
"{...}"
|
|
109
|
-
else
|
|
110
|
-
"..."
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
|
|
114
99
|
# Create a new hash with identity comparison.
|
|
115
100
|
def default_objects
|
|
116
101
|
Hash.new.compare_by_identity
|
|
@@ -123,40 +108,47 @@ module Console
|
|
|
123
108
|
# @parameter objects [Hash] The objects that have already been visited.
|
|
124
109
|
# @returns [Object] The dumped object as a primitive representation.
|
|
125
110
|
def safe_dump_recurse(object, limit = @limit, objects = default_objects)
|
|
126
|
-
if limit <= 0 || objects[object]
|
|
127
|
-
return replacement_for(object)
|
|
128
|
-
end
|
|
129
|
-
|
|
130
111
|
case object
|
|
131
112
|
when Hash
|
|
132
|
-
objects[object]
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
[
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
113
|
+
if limit <= 0 || objects[object]
|
|
114
|
+
return "{...}"
|
|
115
|
+
else
|
|
116
|
+
objects[object] = true
|
|
117
|
+
|
|
118
|
+
return object.to_h do |key, value|
|
|
119
|
+
[
|
|
120
|
+
String(key).encode(@encoding, invalid: :replace, undef: :replace),
|
|
121
|
+
safe_dump_recurse(value, limit - 1, objects)
|
|
122
|
+
]
|
|
123
|
+
end
|
|
139
124
|
end
|
|
140
125
|
when Array
|
|
141
|
-
objects[object]
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
126
|
+
if limit <= 0 || objects[object]
|
|
127
|
+
return "[...]"
|
|
128
|
+
else
|
|
129
|
+
objects[object] = true
|
|
130
|
+
|
|
131
|
+
return object.map do |value|
|
|
132
|
+
safe_dump_recurse(value, limit - 1, objects)
|
|
133
|
+
end
|
|
145
134
|
end
|
|
146
135
|
when String
|
|
147
|
-
object.encode(@encoding, invalid: :replace, undef: :replace)
|
|
136
|
+
return object.encode(@encoding, invalid: :replace, undef: :replace)
|
|
148
137
|
when Numeric, TrueClass, FalseClass, NilClass
|
|
149
|
-
object
|
|
138
|
+
return object
|
|
150
139
|
else
|
|
151
|
-
objects[object]
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
140
|
+
if limit <= 0 || objects[object]
|
|
141
|
+
return "..."
|
|
142
|
+
else
|
|
143
|
+
objects[object] = true
|
|
144
|
+
|
|
145
|
+
# We could do something like this but the chance `as_json` will blow up.
|
|
146
|
+
# We'd need to be extremely careful about it.
|
|
147
|
+
# if object.respond_to?(:as_json)
|
|
148
|
+
# safe_dump_recurse(object.as_json, limit - 1, objects)
|
|
149
|
+
# else
|
|
150
|
+
return safe_dump_recurse(object.to_s, limit - 1, objects)
|
|
151
|
+
end
|
|
160
152
|
end
|
|
161
153
|
end
|
|
162
154
|
end
|
|
@@ -51,11 +51,13 @@ module Console
|
|
|
51
51
|
record = {
|
|
52
52
|
time: Time.now.iso8601,
|
|
53
53
|
severity: severity,
|
|
54
|
-
|
|
55
|
-
oid: subject.object_id,
|
|
54
|
+
process_id: Process.pid,
|
|
56
55
|
fiber_id: Fiber.current.object_id,
|
|
57
56
|
}
|
|
58
57
|
|
|
58
|
+
# For backwards compatibility:
|
|
59
|
+
record[:pid] = record[:process_id]
|
|
60
|
+
|
|
59
61
|
# We want to log just a brief subject:
|
|
60
62
|
if subject.is_a?(String)
|
|
61
63
|
record[:subject] = subject
|
|
@@ -63,6 +65,7 @@ module Console
|
|
|
63
65
|
record[:subject] = subject.name
|
|
64
66
|
else
|
|
65
67
|
record[:subject] = subject.class.name
|
|
68
|
+
record[:object_id] = subject.object_id
|
|
66
69
|
end
|
|
67
70
|
|
|
68
71
|
if annotation = Fiber.current.annotation
|
data/lib/console/version.rb
CHANGED
data/license.md
CHANGED
|
@@ -12,6 +12,7 @@ Copyright, 2022, by William T. Nelson.
|
|
|
12
12
|
Copyright, 2023, by Felix Yan.
|
|
13
13
|
Copyright, 2024-2025, by Patrik Wenger.
|
|
14
14
|
Copyright, 2025, by Shigeru Nakajima.
|
|
15
|
+
Copyright, 2025, by Yasha Krasnou.
|
|
15
16
|
|
|
16
17
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
17
18
|
of this software and associated documentation files (the "Software"), to deal
|
data/readme.md
CHANGED
|
@@ -34,6 +34,11 @@ Please see the [project documentation](https://socketry.github.io/console/) for
|
|
|
34
34
|
|
|
35
35
|
Please see the [project releases](https://socketry.github.io/console/releases/index) for all releases.
|
|
36
36
|
|
|
37
|
+
### v1.34.1
|
|
38
|
+
|
|
39
|
+
- Add `process_id` to serialized output records for clarity (`pid` is still included for backwards compatibility).
|
|
40
|
+
- Add `object_id` to serialized output records **only** when the subject is not a string or class/module.
|
|
41
|
+
|
|
37
42
|
### v1.34.0
|
|
38
43
|
|
|
39
44
|
- Allow `Console::Compatible::Logger#add` to accept `**options`.
|
data/releases.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Releases
|
|
2
2
|
|
|
3
|
+
## v1.34.1
|
|
4
|
+
|
|
5
|
+
- Add `process_id` to serialized output records for clarity (`pid` is still included for backwards compatibility).
|
|
6
|
+
- Add `object_id` to serialized output records **only** when the subject is not a string or class/module.
|
|
7
|
+
|
|
3
8
|
## v1.34.0
|
|
4
9
|
|
|
5
10
|
- Allow `Console::Compatible::Logger#add` to accept `**options`.
|
|
@@ -18,9 +23,9 @@ The console library now works correctly with Ruby's Ractor concurrency model. Pr
|
|
|
18
23
|
``` ruby
|
|
19
24
|
# This now works without errors:
|
|
20
25
|
ractor = Ractor.new do
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
require "console"
|
|
27
|
+
Console.info("Hello from Ractor!")
|
|
28
|
+
"Ractor completed successfully"
|
|
24
29
|
end
|
|
25
30
|
|
|
26
31
|
result = ractor.take
|
|
@@ -81,7 +86,7 @@ def make_logger(output = $stderr, env = ENV, **options)
|
|
|
81
86
|
# Custom logger configuration with verbose output:
|
|
82
87
|
options[:verbose] = true
|
|
83
88
|
|
|
84
|
-
|
|
89
|
+
Logger.new(output, **options)
|
|
85
90
|
end
|
|
86
91
|
```
|
|
87
92
|
|
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.34.
|
|
4
|
+
version: 1.34.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -16,6 +16,7 @@ authors:
|
|
|
16
16
|
- Olle Jonsson
|
|
17
17
|
- Shigeru Nakajima
|
|
18
18
|
- William T. Nelson
|
|
19
|
+
- Yasha Krasnou
|
|
19
20
|
bindir: bin
|
|
20
21
|
cert_chain:
|
|
21
22
|
- |
|
|
@@ -153,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
153
154
|
- !ruby/object:Gem::Version
|
|
154
155
|
version: '0'
|
|
155
156
|
requirements: []
|
|
156
|
-
rubygems_version:
|
|
157
|
+
rubygems_version: 4.0.3
|
|
157
158
|
specification_version: 4
|
|
158
159
|
summary: Beautiful logging for Ruby.
|
|
159
160
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|