console 1.27.0 → 1.28.1
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/bake/console.rb +3 -3
- data/lib/console/capture.rb +1 -1
- data/lib/console/compatible/logger.rb +1 -1
- data/lib/console/event/failure.rb +2 -2
- data/lib/console/event/spawn.rb +2 -2
- data/lib/console/event.rb +2 -2
- data/lib/console/filter.rb +1 -1
- data/lib/console/format/safe.rb +2 -2
- data/lib/console/format.rb +1 -1
- data/lib/console/logger.rb +8 -8
- data/lib/console/output/default.rb +2 -2
- data/lib/console/output/sensitive.rb +1 -1
- data/lib/console/output/serialized.rb +3 -3
- data/lib/console/output/terminal.rb +7 -7
- 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/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 +37 -0
- data/lib/console.rb +3 -2
- data/readme.md +10 -0
- data/releases.md +5 -0
- data.tar.gz.sig +0 -0
- metadata +4 -2
- metadata.gz.sig +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c1e55ddfff39c11445d128d77669db8d27047b5bb52451c0dcd41986b9efe99
|
4
|
+
data.tar.gz: 314cd06dc220bc184899c393d68ef8e0387e92bbeb39522b2ec9ab11b408cb01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2b5c3d3d01818a45f7680e07417c5c6bb805caa81c5a598d7a4c83fa77363cdbf241eb5f00327ff835c130ebe53994f34c923c50304c972d01b714fba638263
|
7
|
+
data.tar.gz: 6cc85f8a898133e9af736f89b0d12cda37fdc46f2467131e89b6784842a8cdff9757f0981cf18c7ae0cbf1b21d005aaf4f7b9f647c891ec96b790833446c4fcd
|
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
@@ -5,7 +5,7 @@
|
|
5
5
|
# Copyright, 2021, by Robert Schulze.
|
6
6
|
# Copyright, 2024, by Patrik Wenger.
|
7
7
|
|
8
|
-
require_relative
|
8
|
+
require_relative "generic"
|
9
9
|
|
10
10
|
module Console
|
11
11
|
module Event
|
@@ -59,7 +59,7 @@ module Console
|
|
59
59
|
message = exception.detailed_message
|
60
60
|
|
61
61
|
# We want to remove the trailling exception class as we format it differently:
|
62
|
-
message.sub!(/\s*\(.*?\)$/,
|
62
|
+
message.sub!(/\s*\(.*?\)$/, "")
|
63
63
|
|
64
64
|
hash[:message] = message
|
65
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)
|
data/lib/console/format/safe.rb
CHANGED
data/lib/console/format.rb
CHANGED
data/lib/console/logger.rb
CHANGED
@@ -5,13 +5,13 @@
|
|
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
|
11
|
-
require_relative
|
12
|
-
require_relative
|
8
|
+
require_relative "output"
|
9
|
+
require_relative "filter"
|
10
|
+
require_relative "event"
|
11
|
+
require_relative "resolver"
|
12
|
+
require_relative "progress"
|
13
13
|
|
14
|
-
require
|
14
|
+
require "fiber/local"
|
15
15
|
|
16
16
|
module Console
|
17
17
|
class Logger < Filter[debug: 0, info: 1, warn: 2, error: 3, fatal: 4]
|
@@ -21,7 +21,7 @@ module Console
|
|
21
21
|
# You can also specify CONSOLE_LEVEL=debug or CONSOLE_LEVEL=info in environment.
|
22
22
|
# https://mislav.net/2011/06/ruby-verbose-mode/ has more details about how it all fits together.
|
23
23
|
def self.default_log_level(env = ENV)
|
24
|
-
if level = env[
|
24
|
+
if level = env["CONSOLE_LEVEL"]
|
25
25
|
LEVELS[level.to_sym] || level.to_i
|
26
26
|
elsif $DEBUG
|
27
27
|
DEBUG
|
@@ -34,7 +34,7 @@ module Console
|
|
34
34
|
|
35
35
|
# Controls verbose output using `$VERBOSE`.
|
36
36
|
def self.verbose?(env = ENV)
|
37
|
-
!$VERBOSE.nil? || env[
|
37
|
+
!$VERBOSE.nil? || env["CONSOLE_VERBOSE"]
|
38
38
|
end
|
39
39
|
|
40
40
|
def self.default_logger(output = $stderr, env = ENV, **options)
|
@@ -3,9 +3,9 @@
|
|
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
|
@@ -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)
|
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,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2024, by Samuel Williams.
|
5
|
+
|
6
|
+
module Console
|
7
|
+
# Whether the current fiber is emitting a warning.
|
8
|
+
Fiber.attr_accessor :console_warn
|
9
|
+
|
10
|
+
module Warn
|
11
|
+
def warn(*arguments, uplevel: nil, **options)
|
12
|
+
fiber = Fiber.current
|
13
|
+
|
14
|
+
# We do this to be extra pendantic about avoiding infinite recursion, i.e. if `Console.warn` some how calls `Kernel.warn` again, it would potentially cause infinite recursion. I'm not sure if this is a problem in practice, but I'd rather not find out the hard way...
|
15
|
+
return super if fiber.console_warn
|
16
|
+
|
17
|
+
if uplevel
|
18
|
+
options[:backtrace] = caller(uplevel, 1)
|
19
|
+
end
|
20
|
+
|
21
|
+
if arguments.last.is_a?(Exception)
|
22
|
+
exception = arguments.pop
|
23
|
+
|
24
|
+
Console::Event::Failure.for(exception).emit(*arguments, severity: :warn)
|
25
|
+
else
|
26
|
+
begin
|
27
|
+
fiber.console_warn = true
|
28
|
+
Console.warn(*arguments, **options)
|
29
|
+
ensure
|
30
|
+
fiber.console_warn = false
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
::Kernel.prepend(Warn)
|
37
|
+
end
|
data/lib/console.rb
CHANGED
@@ -6,8 +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/logger"
|
11
|
+
require_relative "console/warn"
|
11
12
|
|
12
13
|
module Console
|
13
14
|
class << self
|
data/readme.md
CHANGED
@@ -26,6 +26,16 @@ 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.28.0
|
36
|
+
|
37
|
+
- Add support for `Kernel#warn` redirection to `Console.warn`.
|
38
|
+
|
29
39
|
## Contributing
|
30
40
|
|
31
41
|
We welcome contributions to this project.
|
data/releases.md
ADDED
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.28.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -47,7 +47,7 @@ cert_chain:
|
|
47
47
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
48
48
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
49
49
|
-----END CERTIFICATE-----
|
50
|
-
date: 2024-
|
50
|
+
date: 2024-11-05 00:00:00.000000000 Z
|
51
51
|
dependencies:
|
52
52
|
- !ruby/object:Gem::Dependency
|
53
53
|
name: fiber-annotation
|
@@ -128,8 +128,10 @@ files:
|
|
128
128
|
- lib/console/terminal/text.rb
|
129
129
|
- lib/console/terminal/xterm.rb
|
130
130
|
- lib/console/version.rb
|
131
|
+
- lib/console/warn.rb
|
131
132
|
- license.md
|
132
133
|
- readme.md
|
134
|
+
- releases.md
|
133
135
|
homepage: https://socketry.github.io/console
|
134
136
|
licenses:
|
135
137
|
- MIT
|
metadata.gz.sig
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
t�Q�na�f���P�x�y:r,ڪ�i�w�]c,��/Hl�N%��f�8�]܅u��7~(ol�ŚыD�M
|
2
|
+
��G\�3��:��à�qoN��@����
|
3
|
+
T0�1���G��Y���3����ܸeF �i�f;����(�EғS�lD�"�{��f�������� .��nz���;
|
4
|
+
"�p"�-g�a�_�:)�a�k'8Ճ"C���@L��b�ܑ���{�?�iN�A4m3\�D5�
|
5
|
+
�G�H\j=l!��d9�RE�
|