console 1.23.0 → 1.24.0
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 +0 -0
- data/lib/console/capture.rb +5 -1
- data/lib/console/compatible/logger.rb +1 -1
- data/lib/console/event/failure.rb +12 -2
- data/lib/console/filter.rb +14 -3
- data/lib/console/format/safe.rb +41 -3
- data/lib/console/output/json.rb +1 -1
- data/lib/console/terminal/logger.rb +10 -3
- data/lib/console/version.rb +1 -1
- data/license.md +1 -1
- data/readme.md +14 -2
- data.tar.gz.sig +0 -0
- metadata +18 -4
- 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: 9a62f7c19673292c5cd3c0d8b9d93350ca4b36ac0a5c0a0466deef6543b388ba
|
|
4
|
+
data.tar.gz: f382353a7b052c056936fdd2c95ad0bd20cfb8619db2f6d2af1ce7e9e0cd7967
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6638ede52de5f0954a38adf71e910997eb643d2e39ef59645f320ce16ebefd4f804cb062e47e03472ac742fb46591c310217da72eb63eb87fe91d93090f8ee5f
|
|
7
|
+
data.tar.gz: 15f4929956b45e0c445e95774dfa3ac1c4bb485401e1b0003835c9ae5435a25ebda70b69ad475cf0e6b48131b0cc41258e3c5bb8c70121daaa9fe482c12b5404
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/console/capture.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Released under the MIT License.
|
|
4
|
-
# Copyright, 2019-
|
|
4
|
+
# Copyright, 2019-2023, by Samuel Williams.
|
|
5
5
|
|
|
6
6
|
require_relative 'filter'
|
|
7
7
|
|
|
@@ -55,6 +55,10 @@ module Console
|
|
|
55
55
|
message[:arguments] = arguments
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
+
if annotation = Fiber.current.annotation
|
|
59
|
+
message[:annotation] = annotation
|
|
60
|
+
end
|
|
61
|
+
|
|
58
62
|
if block_given?
|
|
59
63
|
if block.arity.zero?
|
|
60
64
|
message[:message] = yield
|
|
@@ -43,8 +43,18 @@ module Console
|
|
|
43
43
|
format_exception(@exception, nil, output, terminal, verbose)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
+
if Exception.method_defined?(:detailed_message)
|
|
47
|
+
def detailed_message(exception)
|
|
48
|
+
exception.detailed_message
|
|
49
|
+
end
|
|
50
|
+
else
|
|
51
|
+
def detailed_message(exception)
|
|
52
|
+
exception.message
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
46
56
|
def format_exception(exception, prefix, output, terminal, verbose)
|
|
47
|
-
lines = exception.
|
|
57
|
+
lines = detailed_message(exception).lines.map(&:chomp)
|
|
48
58
|
|
|
49
59
|
output.puts " #{prefix}#{terminal[:exception_title]}#{exception.class}#{terminal.reset}: #{lines.shift}"
|
|
50
60
|
|
|
@@ -55,7 +65,7 @@ module Console
|
|
|
55
65
|
root_pattern = /^#{@root}\// if @root
|
|
56
66
|
|
|
57
67
|
exception.backtrace&.each_with_index do |line, index|
|
|
58
|
-
path, offset, message = line.split(":")
|
|
68
|
+
path, offset, message = line.split(":", 3)
|
|
59
69
|
style = :exception_backtrace
|
|
60
70
|
|
|
61
71
|
# Make the path a bit more readable
|
data/lib/console/filter.rb
CHANGED
|
@@ -12,6 +12,17 @@ module Console
|
|
|
12
12
|
UNKNOWN = 'unknown'
|
|
13
13
|
|
|
14
14
|
class Filter
|
|
15
|
+
if Object.const_defined?(:Ractor) and RUBY_VERSION >= '3.1'
|
|
16
|
+
def self.define_immutable_method(name, &block)
|
|
17
|
+
block = Ractor.make_shareable(block)
|
|
18
|
+
self.define_method(name, &block)
|
|
19
|
+
end
|
|
20
|
+
else
|
|
21
|
+
def self.define_immutable_method(name, &block)
|
|
22
|
+
define_method(name, &block)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
15
26
|
def self.[] **levels
|
|
16
27
|
klass = Class.new(self)
|
|
17
28
|
minimum_level, maximum_level = levels.values.minmax
|
|
@@ -24,17 +35,17 @@ module Console
|
|
|
24
35
|
levels.each do |name, level|
|
|
25
36
|
const_set(name.to_s.upcase, level)
|
|
26
37
|
|
|
27
|
-
|
|
38
|
+
define_immutable_method(name) do |subject = nil, *arguments, **options, &block|
|
|
28
39
|
if self.enabled?(subject, level)
|
|
29
40
|
self.call(subject, *arguments, severity: name, **options, **@options, &block)
|
|
30
41
|
end
|
|
31
42
|
end
|
|
32
43
|
|
|
33
|
-
|
|
44
|
+
define_immutable_method("#{name}!") do
|
|
34
45
|
@level = level
|
|
35
46
|
end
|
|
36
47
|
|
|
37
|
-
|
|
48
|
+
define_immutable_method("#{name}?") do
|
|
38
49
|
@level <= level
|
|
39
50
|
end
|
|
40
51
|
end
|
data/lib/console/format/safe.rb
CHANGED
|
@@ -18,14 +18,47 @@ module Console
|
|
|
18
18
|
|
|
19
19
|
def dump(object)
|
|
20
20
|
@format.dump(object, @limit)
|
|
21
|
-
rescue => error
|
|
21
|
+
rescue SystemStackError, StandardError => error
|
|
22
22
|
@format.dump(safe_dump(object, error))
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
private
|
|
26
26
|
|
|
27
|
-
def
|
|
28
|
-
|
|
27
|
+
def filter_backtrace(error)
|
|
28
|
+
frames = error.backtrace
|
|
29
|
+
filtered = {}
|
|
30
|
+
filtered_count = nil
|
|
31
|
+
skipped = nil
|
|
32
|
+
|
|
33
|
+
frames = frames.filter_map do |frame|
|
|
34
|
+
if filtered[frame]
|
|
35
|
+
if filtered_count == nil
|
|
36
|
+
filtered_count = 1
|
|
37
|
+
skipped = frame.dup
|
|
38
|
+
else
|
|
39
|
+
filtered_count += 1
|
|
40
|
+
nil
|
|
41
|
+
end
|
|
42
|
+
else
|
|
43
|
+
if skipped
|
|
44
|
+
if filtered_count > 1
|
|
45
|
+
skipped.replace("[... #{filtered_count} frames skipped ...]")
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
filtered_count = nil
|
|
49
|
+
skipped = nil
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
filtered[frame] = true
|
|
53
|
+
frame
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
if skipped && filtered_count > 1
|
|
58
|
+
skipped.replace("[... #{filtered_count} frames skipped ...]")
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
return frames
|
|
29
62
|
end
|
|
30
63
|
|
|
31
64
|
def safe_dump(object, error)
|
|
@@ -35,6 +68,7 @@ module Console
|
|
|
35
68
|
object[:error] = {
|
|
36
69
|
class: safe_dump_recurse(error.class.name),
|
|
37
70
|
message: safe_dump_recurse(error.message),
|
|
71
|
+
backtrace: safe_dump_recurse(filter_backtrace(error)),
|
|
38
72
|
}
|
|
39
73
|
|
|
40
74
|
return object
|
|
@@ -51,6 +85,10 @@ module Console
|
|
|
51
85
|
end
|
|
52
86
|
end
|
|
53
87
|
|
|
88
|
+
def default_objects
|
|
89
|
+
Hash.new.compare_by_identity
|
|
90
|
+
end
|
|
91
|
+
|
|
54
92
|
# This will recursively generate a safe version of the object.
|
|
55
93
|
# Nested hashes and arrays will be transformed recursively.
|
|
56
94
|
# Strings will be encoded with the given encoding.
|
data/lib/console/output/json.rb
CHANGED
|
@@ -119,7 +119,7 @@ module Console
|
|
|
119
119
|
protected
|
|
120
120
|
|
|
121
121
|
def format_options(options, output)
|
|
122
|
-
format_value(options
|
|
122
|
+
format_value(::JSON.pretty_generate(options), output)
|
|
123
123
|
end
|
|
124
124
|
|
|
125
125
|
def format_argument(argument, output)
|
|
@@ -149,8 +149,14 @@ module Console
|
|
|
149
149
|
buffer = +""
|
|
150
150
|
|
|
151
151
|
if @verbose
|
|
152
|
-
if annotation = Fiber.current.annotation
|
|
153
|
-
|
|
152
|
+
if annotation = Fiber.current.annotation
|
|
153
|
+
# While typically annotations should be strings, that is not always the case.
|
|
154
|
+
annotation = annotation.to_s
|
|
155
|
+
|
|
156
|
+
# If the annotation is empty, we don't want to print it, as it will look like a formatting bug.
|
|
157
|
+
if annotation.size > 0
|
|
158
|
+
buffer << ": #{@terminal[:annotation]}#{annotation}#{@terminal.reset}"
|
|
159
|
+
end
|
|
154
160
|
end
|
|
155
161
|
end
|
|
156
162
|
|
|
@@ -193,6 +199,7 @@ module Console
|
|
|
193
199
|
string = value.to_s
|
|
194
200
|
|
|
195
201
|
string.each_line do |line|
|
|
202
|
+
line.chomp!
|
|
196
203
|
output.puts "#{@terminal[:value]}#{line}#{@terminal.reset}"
|
|
197
204
|
end
|
|
198
205
|
end
|
data/lib/console/version.rb
CHANGED
data/license.md
CHANGED
data/readme.md
CHANGED
|
@@ -18,7 +18,13 @@ When Ruby decided to reverse the order of exception backtraces, I finally gave u
|
|
|
18
18
|
|
|
19
19
|
## Usage
|
|
20
20
|
|
|
21
|
-
Please see the [project documentation](https://socketry.github.io/console).
|
|
21
|
+
Please see the [project documentation](https://socketry.github.io/console/) for more details.
|
|
22
|
+
|
|
23
|
+
- [Getting Started](https://socketry.github.io/console/guides/getting-started/index) - This guide explains how to use `console` for logging.
|
|
24
|
+
|
|
25
|
+
- [Command Line](https://socketry.github.io/console/guides/command-line/index) - This guide explains how the `console` gem can be controlled using environment variables.
|
|
26
|
+
|
|
27
|
+
- [Integration](https://socketry.github.io/console/guides/integration/index) - This guide explains how to integrate the `console` output into different systems.
|
|
22
28
|
|
|
23
29
|
## Contributing
|
|
24
30
|
|
|
@@ -36,4 +42,10 @@ This project uses the [Developer Certificate of Origin](https://developercertifi
|
|
|
36
42
|
|
|
37
43
|
### Contributor Covenant
|
|
38
44
|
|
|
39
|
-
This project is governed by [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
|
|
45
|
+
This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
|
|
46
|
+
|
|
47
|
+
## See Also
|
|
48
|
+
|
|
49
|
+
- [console-adapter-rails](https://github.com/socketry/console-adapter-rails)
|
|
50
|
+
- [console-adapter-sidekiq](https://github.com/socketry/console-adapter-sidekiq)
|
|
51
|
+
- [console-output-datadog](https://github.com/socketry/console-output-datadog)
|
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.24.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:
|
|
49
|
+
date: 2024-04-22 00:00:00.000000000 Z
|
|
50
50
|
dependencies:
|
|
51
51
|
- !ruby/object:Gem::Dependency
|
|
52
52
|
name: fiber-annotation
|
|
@@ -76,6 +76,20 @@ dependencies:
|
|
|
76
76
|
- - ">="
|
|
77
77
|
- !ruby/object:Gem::Version
|
|
78
78
|
version: '0'
|
|
79
|
+
- !ruby/object:Gem::Dependency
|
|
80
|
+
name: json
|
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
|
82
|
+
requirements:
|
|
83
|
+
- - ">="
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: '0'
|
|
86
|
+
type: :runtime
|
|
87
|
+
prerelease: false
|
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
89
|
+
requirements:
|
|
90
|
+
- - ">="
|
|
91
|
+
- !ruby/object:Gem::Version
|
|
92
|
+
version: '0'
|
|
79
93
|
description:
|
|
80
94
|
email:
|
|
81
95
|
executables: []
|
|
@@ -117,7 +131,7 @@ files:
|
|
|
117
131
|
- lib/console/version.rb
|
|
118
132
|
- license.md
|
|
119
133
|
- readme.md
|
|
120
|
-
homepage: https://github.
|
|
134
|
+
homepage: https://socketry.github.io/console/
|
|
121
135
|
licenses:
|
|
122
136
|
- MIT
|
|
123
137
|
metadata: {}
|
|
@@ -136,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
136
150
|
- !ruby/object:Gem::Version
|
|
137
151
|
version: '0'
|
|
138
152
|
requirements: []
|
|
139
|
-
rubygems_version: 3.
|
|
153
|
+
rubygems_version: 3.5.3
|
|
140
154
|
signing_key:
|
|
141
155
|
specification_version: 4
|
|
142
156
|
summary: Beautiful logging for Ruby.
|
metadata.gz.sig
CHANGED
|
Binary file
|