console 1.30.0 → 1.31.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 +1 -1
- data/lib/console/clock.rb +1 -1
- data/lib/console/compatible/logger.rb +1 -1
- data/lib/console/config.rb +4 -1
- data/lib/console/event/failure.rb +1 -1
- data/lib/console/event/generic.rb +8 -1
- data/lib/console/event/spawn.rb +1 -1
- data/lib/console/event.rb +1 -1
- data/lib/console/filter.rb +10 -4
- data/lib/console/format/safe.rb +1 -1
- data/lib/console/format.rb +1 -1
- data/lib/console/logger.rb +4 -2
- data/lib/console/output/default.rb +15 -3
- data/lib/console/output/null.rb +1 -1
- data/lib/console/output/sensitive.rb +1 -1
- data/lib/console/output/split.rb +1 -1
- data/lib/console/output/terminal.rb +1 -1
- data/lib/console/output/wrapper.rb +1 -1
- data/lib/console/output.rb +1 -1
- data/lib/console/progress.rb +1 -1
- data/lib/console/resolver.rb +1 -1
- data/lib/console/terminal/formatter/failure.rb +1 -1
- data/lib/console/terminal/formatter/progress.rb +1 -1
- data/lib/console/terminal/formatter/spawn.rb +1 -1
- data/lib/console/terminal/text.rb +9 -5
- data/lib/console/terminal/xterm.rb +1 -1
- data/lib/console/terminal.rb +1 -1
- data/lib/console/version.rb +2 -2
- data/lib/console/warn.rb +1 -1
- data/lib/console.rb +1 -1
- data/license.md +1 -0
- data/readme.md +6 -0
- data/releases.md +55 -0
- data.tar.gz.sig +0 -0
- metadata +5 -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: 356c92cbef3eb3269b7dada97f281c832304e0cad9885102e63c7d6725196df2
|
4
|
+
data.tar.gz: 1f957d68282bea484c6abddd507dcb886930c727d148f9dfa4f02f482724c234
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7400992949682404ecd931375c098c103105c5d513897c933f56be31ac7b8d96e81ea12eb85ad012b91358ee14309684f3321a7704dd25717f581c04cb51fdc
|
7
|
+
data.tar.gz: 02a3052cb5169303820e55bbe7c13bc6d9564ffd1df810b8a0329814fd2b84a0a1da3b12c008569cb4133cdd2e7e63d08153ec24ee72f786487c049f60432893
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/console/capture.rb
CHANGED
data/lib/console/clock.rb
CHANGED
data/lib/console/config.rb
CHANGED
@@ -30,12 +30,15 @@ module Console
|
|
30
30
|
# Load the default configuration.
|
31
31
|
# @returns [Config] The default configuration.
|
32
32
|
def self.default
|
33
|
-
@default ||= self.load(PATH)
|
33
|
+
@default ||= self.load(PATH).freeze
|
34
34
|
end
|
35
35
|
|
36
36
|
# Set the default log level based on `$DEBUG` and `$VERBOSE`.
|
37
37
|
# You can also specify CONSOLE_LEVEL=debug or CONSOLE_LEVEL=info in environment.
|
38
38
|
# https://mislav.net/2011/06/ruby-verbose-mode/ has more details about how it all fits together.
|
39
|
+
#
|
40
|
+
# @parameter env [Hash] The environment to read the log level from.
|
41
|
+
# @returns [Integer | Symbol] The default log level.
|
39
42
|
def log_level(env = ENV)
|
40
43
|
Logger.default_log_level(env)
|
41
44
|
end
|
@@ -1,12 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2019-
|
4
|
+
# Copyright, 2019-2025, by Samuel Williams.
|
5
5
|
|
6
6
|
module Console
|
7
7
|
module Event
|
8
8
|
# A generic event which can be used to represent structured data.
|
9
9
|
class Generic
|
10
|
+
# Convert the event to a hash suitable for JSON serialization.
|
11
|
+
#
|
12
|
+
# @returns [Hash] The hash representation of the event.
|
13
|
+
def to_hash
|
14
|
+
{}
|
15
|
+
end
|
16
|
+
|
10
17
|
# Convert the event to a hash suitable for JSON serialization.
|
11
18
|
#
|
12
19
|
# @returns [Hash] The hash representation of the event.
|
data/lib/console/event/spawn.rb
CHANGED
data/lib/console/event.rb
CHANGED
data/lib/console/filter.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-2025, by Samuel Williams.
|
5
5
|
# Copyright, 2019, by Bryan Powell.
|
6
6
|
# Copyright, 2020, by Michael Adams.
|
7
7
|
# Copyright, 2021, by Robert Schulze.
|
@@ -70,10 +70,16 @@ module Console
|
|
70
70
|
# @parameter verbose [Boolean] Enable verbose output.
|
71
71
|
# @parameter level [Integer] The log level.
|
72
72
|
# @parameter options [Hash] Additional options.
|
73
|
-
def initialize(output, verbose: true, level:
|
73
|
+
def initialize(output, verbose: true, level: nil, **options)
|
74
74
|
@output = output
|
75
75
|
@verbose = verbose
|
76
|
-
|
76
|
+
|
77
|
+
# Set the log level using the behaviour implemented in `level=`:
|
78
|
+
if level
|
79
|
+
self.level = level
|
80
|
+
else
|
81
|
+
@level = self.class::DEFAULT_LEVEL
|
82
|
+
end
|
77
83
|
|
78
84
|
@subjects = {}
|
79
85
|
|
@@ -156,7 +162,7 @@ module Console
|
|
156
162
|
#
|
157
163
|
# You can enable and disable logging for classes. This function checks if logging for a given subject is enabled.
|
158
164
|
#
|
159
|
-
# @parameter subject [Module] The subject to check.
|
165
|
+
# @parameter subject [Module | Object] The subject to check.
|
160
166
|
# @parameter level [Integer] The log level.
|
161
167
|
# @returns [Boolean] Whether logging is enabled.
|
162
168
|
def enabled?(subject, level = self.class::MINIMUM_LEVEL)
|
data/lib/console/format/safe.rb
CHANGED
data/lib/console/format.rb
CHANGED
data/lib/console/logger.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2019-
|
4
|
+
# Copyright, 2019-2025, by Samuel Williams.
|
5
5
|
# Copyright, 2021, by Bryan Powell.
|
6
6
|
# Copyright, 2021, by Robert Schulze.
|
7
|
+
# Copyright, 2025, by Shigeru Nakajima.
|
8
|
+
|
9
|
+
require_relative "filter"
|
7
10
|
|
8
11
|
require_relative "output"
|
9
12
|
require_relative "output/failure"
|
10
13
|
|
11
14
|
require_relative "progress"
|
12
|
-
require_relative "config"
|
13
15
|
|
14
16
|
module Console
|
15
17
|
# The standard logger interface with support for log levels and verbosity.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2021-
|
4
|
+
# Copyright, 2021-2025, by Samuel Williams.
|
5
5
|
|
6
6
|
require_relative "terminal"
|
7
7
|
require_relative "serialized"
|
@@ -14,12 +14,13 @@ module Console
|
|
14
14
|
# Create a new output format based on the given stream.
|
15
15
|
#
|
16
16
|
# @parameter io [IO] The output stream.
|
17
|
+
# @parameter env [Hash] Environment variables (defaults to ENV for testing).
|
17
18
|
# @parameter options [Hash] Additional options to customize the output.
|
18
19
|
# @returns [Console::Output::Terminal | Console::Output::Serialized] The output instance, depending on whether the `io` is a terminal or not.
|
19
|
-
def self.new(stream, **options)
|
20
|
+
def self.new(stream, env: ENV, **options)
|
20
21
|
stream ||= $stderr
|
21
22
|
|
22
|
-
if stream.tty?
|
23
|
+
if stream.tty? || mail?(env)
|
23
24
|
output = Terminal.new(stream, **options)
|
24
25
|
else
|
25
26
|
output = Serialized.new(stream, **options)
|
@@ -27,6 +28,17 @@ module Console
|
|
27
28
|
|
28
29
|
return output
|
29
30
|
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
# Detect if we're running in a cron job or mail context where human-readable output is preferred.
|
35
|
+
# Cron jobs often have MAILTO set and lack TERM, or have minimal TERM values.
|
36
|
+
def self.mail?(env = ENV)
|
37
|
+
# Check for common cron environment indicators
|
38
|
+
return true if env.key?("MAILTO") && !env["MAILTO"].empty?
|
39
|
+
|
40
|
+
false
|
41
|
+
end
|
30
42
|
end
|
31
43
|
end
|
32
44
|
end
|
data/lib/console/output/null.rb
CHANGED
data/lib/console/output/split.rb
CHANGED
data/lib/console/output.rb
CHANGED
data/lib/console/progress.rb
CHANGED
data/lib/console/resolver.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-2025, by Samuel Williams.
|
5
5
|
|
6
6
|
require "io/console"
|
7
7
|
|
@@ -78,15 +78,19 @@ module Console
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
# Write the given arguments to the output stream using the given style. The reset sequence is automatically
|
81
|
+
# Write the given arguments to the output stream using the given style. The reset sequence is automatically
|
82
|
+
# appended at the end of each line.
|
82
83
|
#
|
83
84
|
# @parameter arguments [Array] The arguments to write, each on a new line.
|
84
85
|
# @parameter style [Symbol] The style to apply.
|
85
86
|
def puts(*arguments, style: nil)
|
86
87
|
if style and prefix = self[style]
|
87
|
-
|
88
|
-
|
89
|
-
|
88
|
+
arguments.each do |argument|
|
89
|
+
argument.to_s.lines.each do |line|
|
90
|
+
@stream.write(prefix, line.chomp)
|
91
|
+
@stream.puts(self.reset)
|
92
|
+
end
|
93
|
+
end
|
90
94
|
else
|
91
95
|
@stream.puts(*arguments)
|
92
96
|
end
|
data/lib/console/terminal.rb
CHANGED
data/lib/console/version.rb
CHANGED
data/lib/console/warn.rb
CHANGED
data/lib/console.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-2025, by Samuel Williams.
|
5
5
|
# Copyright, 2019, by Bryan Powell.
|
6
6
|
# Copyright, 2020, by Michael Adams.
|
7
7
|
# Copyright, 2021, by Cédric Boutillier.
|
data/license.md
CHANGED
@@ -11,6 +11,7 @@ Copyright, 2022, by Anton Sozontov.
|
|
11
11
|
Copyright, 2022, by William T. Nelson.
|
12
12
|
Copyright, 2023, by Felix Yan.
|
13
13
|
Copyright, 2024, by Patrik Wenger.
|
14
|
+
Copyright, 2025, by Shigeru Nakajima.
|
14
15
|
|
15
16
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
16
17
|
of this software and associated documentation files (the "Software"), to deal
|
data/readme.md
CHANGED
@@ -34,6 +34,12 @@ 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.31.0
|
38
|
+
|
39
|
+
- [Ractor compatibility.](https://socketry.github.io/console/releases/index#ractor-compatibility.)
|
40
|
+
- [Symbol log level compatibility.](https://socketry.github.io/console/releases/index#symbol-log-level-compatibility.)
|
41
|
+
- [Improved output format selection for cron jobs and email contexts.](https://socketry.github.io/console/releases/index#improved-output-format-selection-for-cron-jobs-and-email-contexts.)
|
42
|
+
|
37
43
|
### v1.30.0
|
38
44
|
|
39
45
|
- [Introduce `Console::Config` for fine grained configuration.](https://socketry.github.io/console/releases/index#introduce-console::config-for-fine-grained-configuration.)
|
data/releases.md
CHANGED
@@ -1,5 +1,60 @@
|
|
1
1
|
# Releases
|
2
2
|
|
3
|
+
## v1.31.0
|
4
|
+
|
5
|
+
### Ractor compatibility.
|
6
|
+
|
7
|
+
The console library now works correctly with Ruby's Ractor concurrency model. Previously, attempting to use console logging within Ractors would fail with errors about non-shareable objects. This has been fixed by ensuring the default configuration is properly frozen.
|
8
|
+
|
9
|
+
``` ruby
|
10
|
+
# This now works without errors:
|
11
|
+
ractor = Ractor.new do
|
12
|
+
require 'console'
|
13
|
+
Console.info('Hello from Ractor!')
|
14
|
+
'Ractor completed successfully'
|
15
|
+
end
|
16
|
+
|
17
|
+
result = ractor.take
|
18
|
+
puts result # => 'Ractor completed successfully'
|
19
|
+
```
|
20
|
+
|
21
|
+
The fix is minimal and maintains full backward compatibility while enabling safe parallel logging across multiple Ractors.
|
22
|
+
|
23
|
+
### Symbol log level compatibility.
|
24
|
+
|
25
|
+
Previously, returning symbols from custom `log_level` methods in configuration files would cause runtime errors like "comparison of Integer with :debug failed". This has been fixed to properly convert symbols to their corresponding integer values.
|
26
|
+
|
27
|
+
``` ruby
|
28
|
+
# config/console.rb - This now works correctly:
|
29
|
+
def log_level(env = ENV)
|
30
|
+
:debug # Automatically converted to Console::Logger::LEVELS[:debug]
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
While this fix maintains backward compatibility, the recommended approach is still to use integer values directly:
|
35
|
+
|
36
|
+
``` ruby
|
37
|
+
# config/console.rb - Recommended approach:
|
38
|
+
def log_level(env = ENV)
|
39
|
+
Console::Logger::LEVELS[:debug] # Returns 0
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
### Improved output format selection for cron jobs and email contexts.
|
44
|
+
|
45
|
+
When `MAILTO` environment variable is set (typically in cron jobs), the console library now prefers human-readable terminal output instead of JSON serialized output, even when the output stream is not a TTY. This ensures that cron job output sent via email is formatted in a readable way for administrators.
|
46
|
+
|
47
|
+
``` ruby
|
48
|
+
# Previously in cron jobs (non-TTY), this would output JSON:
|
49
|
+
# {"time":"2025-06-07T10:30:00Z","severity":"info","subject":"CronJob","message":["Task completed"]}
|
50
|
+
|
51
|
+
# Now with MAILTO set, it outputs human-readable format:
|
52
|
+
# 0.1s info: CronJob
|
53
|
+
# | Task completed
|
54
|
+
```
|
55
|
+
|
56
|
+
This change is conservative and only affects environments where `MAILTO` is explicitly set, ensuring compatibility with existing deployments.
|
57
|
+
|
3
58
|
## v1.30.0
|
4
59
|
|
5
60
|
### Introduce `Console::Config` for fine grained configuration.
|
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.31.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -14,6 +14,7 @@ authors:
|
|
14
14
|
- Felix Yan
|
15
15
|
- Olle Jonsson
|
16
16
|
- Patrik Wenger
|
17
|
+
- Shigeru Nakajima
|
17
18
|
- William T. Nelson
|
18
19
|
bindir: bin
|
19
20
|
cert_chain:
|
@@ -46,7 +47,7 @@ cert_chain:
|
|
46
47
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
47
48
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
48
49
|
-----END CERTIFICATE-----
|
49
|
-
date:
|
50
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
50
51
|
dependencies:
|
51
52
|
- !ruby/object:Gem::Dependency
|
52
53
|
name: fiber-annotation
|
@@ -145,14 +146,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
146
|
requirements:
|
146
147
|
- - ">="
|
147
148
|
- !ruby/object:Gem::Version
|
148
|
-
version: '3.
|
149
|
+
version: '3.2'
|
149
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
151
|
requirements:
|
151
152
|
- - ">="
|
152
153
|
- !ruby/object:Gem::Version
|
153
154
|
version: '0'
|
154
155
|
requirements: []
|
155
|
-
rubygems_version: 3.6.
|
156
|
+
rubygems_version: 3.6.7
|
156
157
|
specification_version: 4
|
157
158
|
summary: Beautiful logging for Ruby.
|
158
159
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|