console 1.25.2 → 1.29.2
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/bake/console.rb +3 -3
- data/lib/console/capture.rb +39 -18
- data/lib/console/compatible/logger.rb +1 -1
- data/lib/console/event/failure.rb +5 -2
- data/lib/console/event/spawn.rb +2 -2
- data/lib/console/event.rb +2 -2
- data/lib/console/filter.rb +5 -1
- data/lib/console/format/safe.rb +2 -2
- data/lib/console/format.rb +1 -1
- data/lib/console/interface.rb +53 -0
- data/lib/console/logger.rb +14 -23
- data/lib/console/output/default.rb +7 -4
- data/lib/console/output/failure.rb +35 -0
- data/lib/console/output/null.rb +4 -0
- data/lib/console/output/sensitive.rb +2 -2
- data/lib/console/output/serialized.rb +10 -5
- data/lib/console/output/terminal.rb +12 -7
- data/lib/console/output/wrapper.rb +6 -0
- data/lib/console/output.rb +6 -6
- data/lib/console/progress.rb +1 -1
- data/lib/console/resolver.rb +5 -5
- data/lib/console/terminal/formatter/progress.rb +1 -1
- data/lib/console/terminal/text.rb +1 -1
- data/lib/console/terminal/xterm.rb +2 -2
- data/lib/console/terminal.rb +5 -5
- data/lib/console/version.rb +1 -1
- data/lib/console/warn.rb +33 -0
- data/lib/console.rb +3 -35
- data/license.md +1 -0
- data/readme.md +20 -3
- data/releases.md +25 -0
- data.tar.gz.sig +0 -0
- metadata +8 -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: 60457e10e6e444b206349262e1a13a45d2da0fa1aad7ecfa48f22e4b48e44eb8
|
4
|
+
data.tar.gz: 2b9bc10d6e5981286f93fd573e4ca7afad7aa1da9399ec4e8f4f643e38afcc0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a2554093f2fd42567a2cfa5924518a9e689e19394630a88af25d3e89f20a29250d12dc0a63216aa719b49c6dd957f28e79a8fead0a35103a2c5930794791273
|
7
|
+
data.tar.gz: 003a9d78b6d2835b63f202dcbf3d95618339b04a1f363e07b40a6502008be14b0a85a09b114a85d9b136083e8ce9fa4334371c1ba0fe53161d299e2f7cee4da6
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/bake/console.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2020-
|
4
|
+
# Copyright, 2020-2024, by Samuel Williams.
|
5
5
|
|
6
6
|
# Increase the verbosity of the logger to info.
|
7
7
|
def info
|
8
|
-
require_relative
|
8
|
+
require_relative "../lib/console"
|
9
9
|
|
10
10
|
Console.logger.info!
|
11
11
|
end
|
12
12
|
|
13
13
|
# Increase the verbosity of the logger to debug.
|
14
14
|
def debug
|
15
|
-
require_relative
|
15
|
+
require_relative "../lib/console"
|
16
16
|
|
17
17
|
Console.logger.debug!
|
18
18
|
end
|
data/lib/console/capture.rb
CHANGED
@@ -3,33 +3,52 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
6
|
+
require_relative "filter"
|
7
|
+
require_relative "output/failure"
|
7
8
|
|
8
9
|
module Console
|
9
10
|
# A general sink which captures all events into a buffer.
|
10
11
|
class Capture
|
11
12
|
def initialize
|
12
|
-
@
|
13
|
+
@records = []
|
13
14
|
@verbose = false
|
14
15
|
end
|
15
16
|
|
16
|
-
attr :
|
17
|
+
attr :records
|
18
|
+
|
19
|
+
# @deprecated Use {#records} instead of {#buffer}.
|
20
|
+
alias buffer records
|
21
|
+
|
22
|
+
alias to_a records
|
23
|
+
|
17
24
|
attr :verbose
|
18
25
|
|
19
|
-
def
|
20
|
-
@
|
26
|
+
def include?(pattern)
|
27
|
+
@records.any? do |record|
|
28
|
+
record[:subject].to_s&.match?(pattern) or record[:message].to_s&.match?(pattern)
|
29
|
+
end
|
21
30
|
end
|
22
31
|
|
23
|
-
def
|
24
|
-
|
32
|
+
def each(&block)
|
33
|
+
@records.each(&block)
|
34
|
+
end
|
35
|
+
|
36
|
+
include Enumerable
|
37
|
+
|
38
|
+
def first
|
39
|
+
@records.first
|
40
|
+
end
|
41
|
+
|
42
|
+
def last
|
43
|
+
@records.last
|
25
44
|
end
|
26
45
|
|
27
46
|
def clear
|
28
|
-
@
|
47
|
+
@records.clear
|
29
48
|
end
|
30
49
|
|
31
50
|
def empty?
|
32
|
-
@
|
51
|
+
@records.empty?
|
33
52
|
end
|
34
53
|
|
35
54
|
def verbose!(value = true)
|
@@ -40,40 +59,42 @@ module Console
|
|
40
59
|
@verbose
|
41
60
|
end
|
42
61
|
|
43
|
-
def call(subject = nil, *arguments, severity: UNKNOWN, event: nil,
|
44
|
-
|
62
|
+
def call(subject = nil, *arguments, severity: UNKNOWN, event: nil, **options, &block)
|
63
|
+
record = {
|
45
64
|
time: ::Time.now.iso8601,
|
46
65
|
severity: severity,
|
47
66
|
**options,
|
48
67
|
}
|
49
68
|
|
50
69
|
if subject
|
51
|
-
|
70
|
+
record[:subject] = subject
|
52
71
|
end
|
53
72
|
|
54
73
|
if event
|
55
|
-
|
74
|
+
record[:event] = event.to_hash
|
56
75
|
end
|
57
76
|
|
58
77
|
if arguments.any?
|
59
|
-
|
78
|
+
record[:arguments] = arguments
|
60
79
|
end
|
61
80
|
|
62
81
|
if annotation = Fiber.current.annotation
|
63
|
-
|
82
|
+
record[:annotation] = annotation
|
64
83
|
end
|
65
84
|
|
66
85
|
if block_given?
|
67
86
|
if block.arity.zero?
|
68
|
-
|
87
|
+
record[:message] = yield
|
69
88
|
else
|
70
89
|
buffer = StringIO.new
|
71
90
|
yield buffer
|
72
|
-
|
91
|
+
record[:message] = buffer.string
|
73
92
|
end
|
93
|
+
else
|
94
|
+
record[:message] = arguments.join(" ")
|
74
95
|
end
|
75
96
|
|
76
|
-
@
|
97
|
+
@records << record
|
77
98
|
end
|
78
99
|
end
|
79
100
|
end
|
@@ -3,8 +3,9 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
# Copyright, 2021, by Robert Schulze.
|
6
|
+
# Copyright, 2024, by Patrik Wenger.
|
6
7
|
|
7
|
-
require_relative
|
8
|
+
require_relative "generic"
|
8
9
|
|
9
10
|
module Console
|
10
11
|
module Event
|
@@ -28,6 +29,8 @@ module Console
|
|
28
29
|
Console.error(subject, **self.for(exception).to_hash, **options)
|
29
30
|
end
|
30
31
|
|
32
|
+
attr_reader :exception
|
33
|
+
|
31
34
|
def initialize(exception, root = Dir.getwd)
|
32
35
|
@exception = exception
|
33
36
|
@root = root
|
@@ -56,7 +59,7 @@ module Console
|
|
56
59
|
message = exception.detailed_message
|
57
60
|
|
58
61
|
# We want to remove the trailling exception class as we format it differently:
|
59
|
-
message.sub!(/\s*\(.*?\)$/,
|
62
|
+
message.sub!(/\s*\(.*?\)$/, "")
|
60
63
|
|
61
64
|
hash[:message] = message
|
62
65
|
else
|
data/lib/console/event/spawn.rb
CHANGED
data/lib/console/event.rb
CHANGED
data/lib/console/filter.rb
CHANGED
@@ -10,7 +10,7 @@ module Console
|
|
10
10
|
UNKNOWN = :unknown
|
11
11
|
|
12
12
|
class Filter
|
13
|
-
if Object.const_defined?(:Ractor) and RUBY_VERSION >=
|
13
|
+
if Object.const_defined?(:Ractor) and RUBY_VERSION >= "3.1"
|
14
14
|
def self.define_immutable_method(name, &block)
|
15
15
|
block = Ractor.make_shareable(block)
|
16
16
|
self.define_method(name, &block)
|
@@ -37,6 +37,8 @@ module Console
|
|
37
37
|
if self.enabled?(subject, level)
|
38
38
|
@output.call(subject, *arguments, severity: name, **@options, **options, &block)
|
39
39
|
end
|
40
|
+
|
41
|
+
return nil
|
40
42
|
end
|
41
43
|
|
42
44
|
define_immutable_method("#{name}!") do
|
@@ -150,6 +152,8 @@ module Console
|
|
150
152
|
if self.enabled?(subject, level)
|
151
153
|
@output.call(subject, *arguments, **options, &block)
|
152
154
|
end
|
155
|
+
|
156
|
+
return nil
|
153
157
|
end
|
154
158
|
end
|
155
159
|
end
|
data/lib/console/format/safe.rb
CHANGED
data/lib/console/format.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright 2024, by Samuel Williams.
|
5
|
+
|
6
|
+
require_relative "logger"
|
7
|
+
|
8
|
+
module Console
|
9
|
+
# The public logger interface.
|
10
|
+
module Interface
|
11
|
+
# Get the current logger instance.
|
12
|
+
def logger
|
13
|
+
Logger.instance
|
14
|
+
end
|
15
|
+
|
16
|
+
# Set the current logger instance.
|
17
|
+
#
|
18
|
+
# The current logger instance is assigned per-fiber.
|
19
|
+
def logger= instance
|
20
|
+
Logger.instance= instance
|
21
|
+
end
|
22
|
+
|
23
|
+
# Emit a debug log message.
|
24
|
+
def debug(...)
|
25
|
+
Logger.instance.debug(...)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Emit an informational log message.
|
29
|
+
def info(...)
|
30
|
+
Logger.instance.info(...)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Emit a warning log message.
|
34
|
+
def warn(...)
|
35
|
+
Logger.instance.warn(...)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Emit an error log message.
|
39
|
+
def error(...)
|
40
|
+
Logger.instance.error(...)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Emit a fatal log message.
|
44
|
+
def fatal(...)
|
45
|
+
Logger.instance.fatal(...)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Emit a log message with arbitrary arguments and options.
|
49
|
+
def call(...)
|
50
|
+
Logger.instance.call(...)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/console/logger.rb
CHANGED
@@ -5,13 +5,15 @@
|
|
5
5
|
# Copyright, 2021, by Bryan Powell.
|
6
6
|
# Copyright, 2021, by Robert Schulze.
|
7
7
|
|
8
|
-
require_relative
|
9
|
-
require_relative
|
10
|
-
require_relative 'event'
|
11
|
-
require_relative 'resolver'
|
12
|
-
require_relative 'progress'
|
8
|
+
require_relative "output"
|
9
|
+
require_relative "output/failure"
|
13
10
|
|
14
|
-
|
11
|
+
require_relative "filter"
|
12
|
+
require_relative "event"
|
13
|
+
require_relative "resolver"
|
14
|
+
require_relative "progress"
|
15
|
+
|
16
|
+
require "fiber/local"
|
15
17
|
|
16
18
|
module Console
|
17
19
|
class Logger < Filter[debug: 0, info: 1, warn: 2, error: 3, fatal: 4]
|
@@ -21,7 +23,7 @@ module Console
|
|
21
23
|
# You can also specify CONSOLE_LEVEL=debug or CONSOLE_LEVEL=info in environment.
|
22
24
|
# https://mislav.net/2011/06/ruby-verbose-mode/ has more details about how it all fits together.
|
23
25
|
def self.default_log_level(env = ENV)
|
24
|
-
if level = env[
|
26
|
+
if level = env["CONSOLE_LEVEL"]
|
25
27
|
LEVELS[level.to_sym] || level.to_i
|
26
28
|
elsif $DEBUG
|
27
29
|
DEBUG
|
@@ -34,7 +36,7 @@ module Console
|
|
34
36
|
|
35
37
|
# Controls verbose output using `$VERBOSE`.
|
36
38
|
def self.verbose?(env = ENV)
|
37
|
-
!$VERBOSE.nil? || env[
|
39
|
+
!$VERBOSE.nil? || env["CONSOLE_VERBOSE"]
|
38
40
|
end
|
39
41
|
|
40
42
|
def self.default_logger(output = $stderr, env = ENV, **options)
|
@@ -47,6 +49,7 @@ module Console
|
|
47
49
|
end
|
48
50
|
|
49
51
|
output = Output.new(output, env, **options)
|
52
|
+
|
50
53
|
logger = self.new(output, **options)
|
51
54
|
|
52
55
|
Resolver.default_resolver(logger)
|
@@ -61,6 +64,9 @@ module Console
|
|
61
64
|
DEFAULT_LEVEL = 1
|
62
65
|
|
63
66
|
def initialize(output, **options)
|
67
|
+
# This is the expected default behaviour, but it may be nice to have a way to override it.
|
68
|
+
output = Output::Failure.new(output, **options)
|
69
|
+
|
64
70
|
super(output, **options)
|
65
71
|
end
|
66
72
|
|
@@ -69,20 +75,5 @@ module Console
|
|
69
75
|
|
70
76
|
Progress.new(subject, total, **options)
|
71
77
|
end
|
72
|
-
|
73
|
-
def error(subject, *arguments, **options, &block)
|
74
|
-
# This is a special case where we want to create a failure event from an exception.
|
75
|
-
# It's common to see `Console.error(self, exception)` in code.
|
76
|
-
if arguments.first.is_a?(Exception)
|
77
|
-
exception = arguments.shift
|
78
|
-
options[:event] = Event::Failure.for(exception)
|
79
|
-
end
|
80
|
-
|
81
|
-
super
|
82
|
-
end
|
83
|
-
|
84
|
-
def failure(subject, exception, **options)
|
85
|
-
error(subject, event: Event::Failure.for(exception), **options)
|
86
|
-
end
|
87
78
|
end
|
88
79
|
end
|
@@ -3,8 +3,9 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2021-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require_relative
|
6
|
+
require_relative "terminal"
|
7
|
+
require_relative "serialized"
|
8
|
+
require_relative "failure"
|
8
9
|
|
9
10
|
module Console
|
10
11
|
module Output
|
@@ -13,10 +14,12 @@ module Console
|
|
13
14
|
output ||= $stderr
|
14
15
|
|
15
16
|
if output.tty?
|
16
|
-
Terminal.new(output, **options)
|
17
|
+
output = Terminal.new(output, **options)
|
17
18
|
else
|
18
|
-
Serialized.new(output, **options)
|
19
|
+
output = Serialized.new(output, **options)
|
19
20
|
end
|
21
|
+
|
22
|
+
return output
|
20
23
|
end
|
21
24
|
end
|
22
25
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2021-2024, by Samuel Williams.
|
5
|
+
|
6
|
+
require_relative "wrapper"
|
7
|
+
require_relative "../event/failure"
|
8
|
+
|
9
|
+
module Console
|
10
|
+
module Output
|
11
|
+
# A wrapper for outputting failure messages, which can include exceptions.
|
12
|
+
class Failure < Wrapper
|
13
|
+
def initialize(output, **options)
|
14
|
+
super(output, **options)
|
15
|
+
end
|
16
|
+
|
17
|
+
# The exception must be either the last argument or passed as an option.
|
18
|
+
def call(subject = nil, *arguments, exception: nil, **options, &block)
|
19
|
+
if exception.nil?
|
20
|
+
last = arguments.last
|
21
|
+
if last.is_a?(Exception)
|
22
|
+
options[:event] = Event::Failure.for(last)
|
23
|
+
end
|
24
|
+
elsif exception.is_a?(Exception)
|
25
|
+
options[:event] = Event::Failure.for(exception)
|
26
|
+
else
|
27
|
+
# We don't know what this is, so we just pass it through:
|
28
|
+
options[:exception] = exception
|
29
|
+
end
|
30
|
+
|
31
|
+
super(subject, *arguments, **options)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/console/output/null.rb
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2021-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
6
|
+
require_relative "wrapper"
|
7
7
|
|
8
8
|
module Console
|
9
9
|
module Output
|
10
10
|
class Sensitive < Wrapper
|
11
11
|
REDACT = /
|
12
|
-
|
12
|
+
phone
|
13
13
|
| email
|
14
14
|
| full_?name
|
15
15
|
| first_?name
|
@@ -3,18 +3,23 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require
|
8
|
-
require
|
6
|
+
require_relative "../format"
|
7
|
+
require "time"
|
8
|
+
require "fiber/annotation"
|
9
9
|
|
10
10
|
module Console
|
11
11
|
module Output
|
12
12
|
class Serialized
|
13
|
-
def initialize(
|
14
|
-
@io =
|
13
|
+
def initialize(io, format: Format.default, **options)
|
14
|
+
@io = io
|
15
15
|
@format = format
|
16
16
|
end
|
17
17
|
|
18
|
+
# This a final output that then writes to an IO object.
|
19
|
+
def last_output
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
18
23
|
attr :io
|
19
24
|
attr :format
|
20
25
|
|
@@ -4,13 +4,13 @@
|
|
4
4
|
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
# Copyright, 2021, by Robert Schulze.
|
6
6
|
|
7
|
-
require_relative
|
8
|
-
require_relative
|
7
|
+
require_relative "../clock"
|
8
|
+
require_relative "../terminal"
|
9
9
|
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
10
|
+
require "json"
|
11
|
+
require "fiber"
|
12
|
+
require "fiber/annotation"
|
13
|
+
require "stringio"
|
14
14
|
|
15
15
|
module Console
|
16
16
|
module Output
|
@@ -35,7 +35,7 @@ module Console
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# This, and all related methods, is considered private.
|
38
|
-
CONSOLE_START_AT =
|
38
|
+
CONSOLE_START_AT = "CONSOLE_START_AT"
|
39
39
|
|
40
40
|
# Exports CONSOLE_START which can be used to synchronize the start times of all child processes when they log using delta time.
|
41
41
|
def self.start_at!(environment = ENV)
|
@@ -78,6 +78,11 @@ module Console
|
|
78
78
|
self.register_formatters
|
79
79
|
end
|
80
80
|
|
81
|
+
# This a final output that then writes to an IO object.
|
82
|
+
def last_output
|
83
|
+
self
|
84
|
+
end
|
85
|
+
|
81
86
|
attr :io
|
82
87
|
|
83
88
|
attr_accessor :verbose
|
data/lib/console/output.rb
CHANGED
@@ -3,16 +3,16 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2021-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require_relative
|
8
|
-
require_relative
|
9
|
-
require_relative
|
6
|
+
require_relative "output/default"
|
7
|
+
require_relative "output/serialized"
|
8
|
+
require_relative "output/terminal"
|
9
|
+
require_relative "output/null"
|
10
10
|
|
11
11
|
module Console
|
12
12
|
module Output
|
13
13
|
def self.new(output = nil, env = ENV, **options)
|
14
|
-
if names = env[
|
15
|
-
names = names.split(
|
14
|
+
if names = env["CONSOLE_OUTPUT"]
|
15
|
+
names = names.split(",").reverse
|
16
16
|
|
17
17
|
names.inject(output) do |output, name|
|
18
18
|
Output.const_get(name).new(output, **options)
|
data/lib/console/progress.rb
CHANGED
data/lib/console/resolver.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2019-
|
4
|
+
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
# Copyright, 2021, by Robert Schulze.
|
6
6
|
|
7
|
-
require_relative
|
7
|
+
require_relative "filter"
|
8
8
|
|
9
9
|
module Console
|
10
10
|
class Resolver
|
@@ -22,12 +22,12 @@ module Console
|
|
22
22
|
def self.default_resolver(logger, env = ENV)
|
23
23
|
# Find all CONSOLE_$LEVEL variables from environment:
|
24
24
|
levels = logger.class::LEVELS
|
25
|
-
.map{|label, level| [level, env["CONSOLE_#{label.upcase}"]&.split(
|
25
|
+
.map{|label, level| [level, env["CONSOLE_#{label.upcase}"]&.split(",")]}
|
26
26
|
.to_h
|
27
27
|
.compact
|
28
28
|
|
29
|
-
off_klasses = env[
|
30
|
-
on_klasses = env[
|
29
|
+
off_klasses = env["CONSOLE_OFF"]&.split(",")
|
30
|
+
on_klasses = env["CONSOLE_ON"]&.split(",")
|
31
31
|
|
32
32
|
resolver = nil
|
33
33
|
|
data/lib/console/terminal.rb
CHANGED
@@ -3,12 +3,12 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require_relative
|
6
|
+
require_relative "terminal/text"
|
7
|
+
require_relative "terminal/xterm"
|
8
8
|
|
9
|
-
require_relative
|
10
|
-
require_relative
|
11
|
-
require_relative
|
9
|
+
require_relative "terminal/formatter/progress"
|
10
|
+
require_relative "terminal/formatter/failure"
|
11
|
+
require_relative "terminal/formatter/spawn"
|
12
12
|
|
13
13
|
module Console
|
14
14
|
module Terminal
|
data/lib/console/version.rb
CHANGED
data/lib/console/warn.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2024, by Samuel Williams.
|
5
|
+
|
6
|
+
require_relative "logger"
|
7
|
+
|
8
|
+
module Console
|
9
|
+
# Whether the current fiber is emitting a warning.
|
10
|
+
Fiber.attr_accessor :console_warn
|
11
|
+
|
12
|
+
# Redirect warnings to Console.warn.
|
13
|
+
module Warn
|
14
|
+
# Redirect warnings to {Console.warn}.
|
15
|
+
def warn(message, **options)
|
16
|
+
fiber = Fiber.current
|
17
|
+
|
18
|
+
# We do this to be extra pendantic about avoiding infinite recursion.
|
19
|
+
return super if fiber.console_warn
|
20
|
+
|
21
|
+
begin
|
22
|
+
fiber.console_warn = true
|
23
|
+
message.chomp!
|
24
|
+
|
25
|
+
Console::Logger.instance.warn(message, **options)
|
26
|
+
ensure
|
27
|
+
fiber.console_warn = false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
::Warning.extend(Warn)
|
33
|
+
end
|
data/lib/console.rb
CHANGED
@@ -6,41 +6,9 @@
|
|
6
6
|
# Copyright, 2020, by Michael Adams.
|
7
7
|
# Copyright, 2021, by Cédric Boutillier.
|
8
8
|
|
9
|
-
require_relative
|
10
|
-
require_relative
|
9
|
+
require_relative "console/version"
|
10
|
+
require_relative "console/interface"
|
11
11
|
|
12
12
|
module Console
|
13
|
-
|
14
|
-
def logger
|
15
|
-
Logger.instance
|
16
|
-
end
|
17
|
-
|
18
|
-
def logger= instance
|
19
|
-
Logger.instance= instance
|
20
|
-
end
|
21
|
-
|
22
|
-
def debug(...)
|
23
|
-
Logger.instance.debug(...)
|
24
|
-
end
|
25
|
-
|
26
|
-
def info(...)
|
27
|
-
Logger.instance.info(...)
|
28
|
-
end
|
29
|
-
|
30
|
-
def warn(...)
|
31
|
-
Logger.instance.warn(...)
|
32
|
-
end
|
33
|
-
|
34
|
-
def error(...)
|
35
|
-
Logger.instance.error(...)
|
36
|
-
end
|
37
|
-
|
38
|
-
def fatal(...)
|
39
|
-
Logger.instance.fatal(...)
|
40
|
-
end
|
41
|
-
|
42
|
-
def call(...)
|
43
|
-
Logger.instance.call(...)
|
44
|
-
end
|
45
|
-
end
|
13
|
+
Console.extend(Interface)
|
46
14
|
end
|
data/license.md
CHANGED
@@ -10,6 +10,7 @@ Copyright, 2021, by Robert Schulze.
|
|
10
10
|
Copyright, 2022, by Anton Sozontov.
|
11
11
|
Copyright, 2022, by William T. Nelson.
|
12
12
|
Copyright, 2023, by Felix Yan.
|
13
|
+
Copyright, 2024, by Patrik Wenger.
|
13
14
|
|
14
15
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
15
16
|
of this software and associated documentation files (the "Software"), to deal
|
data/readme.md
CHANGED
@@ -26,6 +26,22 @@ Please see the [project documentation](https://socketry.github.io/console/) for
|
|
26
26
|
|
27
27
|
- [Integration](https://socketry.github.io/console/guides/integration/index) - This guide explains how to integrate the `console` output into different systems.
|
28
28
|
|
29
|
+
- [Events](https://socketry.github.io/console/guides/events/index) - This guide explains how to log structured events with a well-defined schema.
|
30
|
+
|
31
|
+
## Releases
|
32
|
+
|
33
|
+
Please see the [project releases](https://socketry.github.io/console/releases/index) for all releases.
|
34
|
+
|
35
|
+
### v1.29.0
|
36
|
+
|
37
|
+
- Don't make `Kernel#warn` redirection to `Console.warn` the default behavior, you must `require 'console/warn'` to enable it.
|
38
|
+
- Remove deprecated `Console::Logger#failure`.
|
39
|
+
- [Consistent Handling of Exceptions](https://socketry.github.io/console/releases/index#consistent-handling-of-exceptions)
|
40
|
+
|
41
|
+
### v1.28.0
|
42
|
+
|
43
|
+
- Add support for `Kernel#warn` redirection to `Console.warn`.
|
44
|
+
|
29
45
|
## Contributing
|
30
46
|
|
31
47
|
We welcome contributions to this project.
|
@@ -38,14 +54,15 @@ We welcome contributions to this project.
|
|
38
54
|
|
39
55
|
### Developer Certificate of Origin
|
40
56
|
|
41
|
-
|
57
|
+
In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
|
42
58
|
|
43
|
-
###
|
59
|
+
### Community Guidelines
|
44
60
|
|
45
|
-
This project is
|
61
|
+
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
|
46
62
|
|
47
63
|
## See Also
|
48
64
|
|
49
65
|
- [console-adapter-rails](https://github.com/socketry/console-adapter-rails)
|
50
66
|
- [console-adapter-sidekiq](https://github.com/socketry/console-adapter-sidekiq)
|
51
67
|
- [console-output-datadog](https://github.com/socketry/console-output-datadog)
|
68
|
+
- [sus-fixtures-console](https://github.com/sus-rb/sus-fixtures-console)
|
data/releases.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Releases
|
2
|
+
|
3
|
+
## v1.29.0
|
4
|
+
|
5
|
+
- Don't make `Kernel#warn` redirection to `Console.warn` the default behavior, you must `require 'console/warn'` to enable it.
|
6
|
+
- Remove deprecated `Console::Logger#failure`.
|
7
|
+
|
8
|
+
### Consistent Handling of Exceptions
|
9
|
+
|
10
|
+
`Console.call` and all wrapper methods will now consistently handle exceptions that are the last positional argument or keyword argument. This means that the following code will work as expected:
|
11
|
+
|
12
|
+
``` ruby
|
13
|
+
begin
|
14
|
+
rescue => error
|
15
|
+
# Last positional argument:
|
16
|
+
Console.warn(self, "There may be an issue", error)
|
17
|
+
|
18
|
+
# Keyword argument (preferable):
|
19
|
+
Console.error(self, "There is an issue", exception: error)
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
## v1.28.0
|
24
|
+
|
25
|
+
- Add support for `Kernel#warn` redirection to `Console.warn`.
|
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.29.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -13,6 +13,7 @@ authors:
|
|
13
13
|
- Cédric Boutillier
|
14
14
|
- Felix Yan
|
15
15
|
- Olle Jonsson
|
16
|
+
- Patrik Wenger
|
16
17
|
- William T. Nelson
|
17
18
|
autorequire:
|
18
19
|
bindir: bin
|
@@ -46,7 +47,7 @@ cert_chain:
|
|
46
47
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
47
48
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
48
49
|
-----END CERTIFICATE-----
|
49
|
-
date: 2024-
|
50
|
+
date: 2024-12-09 00:00:00.000000000 Z
|
50
51
|
dependencies:
|
51
52
|
- !ruby/object:Gem::Dependency
|
52
53
|
name: fiber-annotation
|
@@ -109,9 +110,11 @@ files:
|
|
109
110
|
- lib/console/filter.rb
|
110
111
|
- lib/console/format.rb
|
111
112
|
- lib/console/format/safe.rb
|
113
|
+
- lib/console/interface.rb
|
112
114
|
- lib/console/logger.rb
|
113
115
|
- lib/console/output.rb
|
114
116
|
- lib/console/output/default.rb
|
117
|
+
- lib/console/output/failure.rb
|
115
118
|
- lib/console/output/null.rb
|
116
119
|
- lib/console/output/sensitive.rb
|
117
120
|
- lib/console/output/serialized.rb
|
@@ -127,8 +130,10 @@ files:
|
|
127
130
|
- lib/console/terminal/text.rb
|
128
131
|
- lib/console/terminal/xterm.rb
|
129
132
|
- lib/console/version.rb
|
133
|
+
- lib/console/warn.rb
|
130
134
|
- license.md
|
131
135
|
- readme.md
|
136
|
+
- releases.md
|
132
137
|
homepage: https://socketry.github.io/console
|
133
138
|
licenses:
|
134
139
|
- MIT
|
@@ -149,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
154
|
- !ruby/object:Gem::Version
|
150
155
|
version: '0'
|
151
156
|
requirements: []
|
152
|
-
rubygems_version: 3.5.
|
157
|
+
rubygems_version: 3.5.22
|
153
158
|
signing_key:
|
154
159
|
specification_version: 4
|
155
160
|
summary: Beautiful logging for Ruby.
|
metadata.gz.sig
CHANGED
Binary file
|