console 1.27.0 → 1.28.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93187d6e4774eecaad627306d33a5f38bad4e123e029587d7f142a1265de6ec6
4
- data.tar.gz: 9a5015df0b90995173414eecd2b5b6bff60fe07129db4089cad9c86bdbf1e84f
3
+ metadata.gz: cf762e4b31732049aa1f34fcc17bdb2430489efd671c74f435bfa214ef6290a5
4
+ data.tar.gz: 97ba24a40404eebfd1e2bf6544a673b5131628167ff82e7c933a05322ae5e0bf
5
5
  SHA512:
6
- metadata.gz: d1bc5192624a8c15f464ceac4c5b7f6b3d4340df8a75aff4f5e20b6b42d340872135538b5abb4dd8a2e34f57048536898dee9e07a2c1a0e2e819a1c34b259cc5
7
- data.tar.gz: d61a670deecf0418cd09ed9f1a4d800d2dd5d7b41bd02b3ce2aaa410b27178e62bb7071106a4d7ae89c57fcc4aeadd9ce478a37a1a7859bd20ac00c76c7e1c43
6
+ metadata.gz: d0c1e8fec40b694b8d98f37a4525017e45171160338272c4ca586b58d62575f117e8a36b80226246c43a8476b66d354d56650af70aa96f00489ba8dc8e7e8963
7
+ data.tar.gz: f2f2197d633d2427c4ac9b29706fe59555bbf16bfce0036470c265c0acc86dab8d52884fc844eb7f041ba29c7c330f9d341cbd813859fe4297f59decb56716d7
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-2022, by Samuel Williams.
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 '../lib/console'
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 '../lib/console'
15
+ require_relative "../lib/console"
16
16
 
17
17
  Console.logger.debug!
18
18
  end
@@ -3,7 +3,7 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'filter'
6
+ require_relative "filter"
7
7
 
8
8
  module Console
9
9
  # A general sink which captures all events into a buffer.
@@ -3,7 +3,7 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2022-2024, by Samuel Williams.
5
5
 
6
- require 'logger'
6
+ require "logger"
7
7
 
8
8
  module Console
9
9
  module Compatible
@@ -5,7 +5,7 @@
5
5
  # Copyright, 2021, by Robert Schulze.
6
6
  # Copyright, 2024, by Patrik Wenger.
7
7
 
8
- require_relative 'generic'
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
@@ -3,8 +3,8 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'generic'
7
- require_relative '../clock'
6
+ require_relative "generic"
7
+ require_relative "../clock"
8
8
 
9
9
  module Console
10
10
  module Event
data/lib/console/event.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'event/spawn'
7
- require_relative 'event/failure'
6
+ require_relative "event/spawn"
7
+ require_relative "event/failure"
@@ -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 >= '3.1'
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)
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2023, by Samuel Williams.
4
+ # Copyright, 2023-2024, by Samuel Williams.
5
5
 
6
- require 'json'
6
+ require "json"
7
7
 
8
8
  module Console
9
9
  module Format
@@ -3,7 +3,7 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2023-2024, by Samuel Williams.
5
5
 
6
- require_relative 'format/safe'
6
+ require_relative "format/safe"
7
7
 
8
8
  module Console
9
9
  module Format
@@ -5,13 +5,13 @@
5
5
  # Copyright, 2021, by Bryan Powell.
6
6
  # Copyright, 2021, by Robert Schulze.
7
7
 
8
- require_relative 'output'
9
- require_relative 'filter'
10
- require_relative 'event'
11
- require_relative 'resolver'
12
- require_relative 'progress'
8
+ require_relative "output"
9
+ require_relative "filter"
10
+ require_relative "event"
11
+ require_relative "resolver"
12
+ require_relative "progress"
13
13
 
14
- require 'fiber/local'
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['CONSOLE_LEVEL']
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['CONSOLE_VERBOSE']
37
+ !$VERBOSE.nil? || env["CONSOLE_VERBOSE"]
38
38
  end
39
39
 
40
40
  def self.default_logger(output = $stderr, env = ENV, **options)
@@ -3,8 +3,8 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2021-2024, by Samuel Williams.
5
5
 
6
- require_relative 'terminal'
7
- require_relative 'serialized'
6
+ require_relative "terminal"
7
+ require_relative "serialized"
8
8
 
9
9
  module Console
10
10
  module Output
@@ -3,7 +3,7 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2021-2024, by Samuel Williams.
5
5
 
6
- require_relative 'wrapper'
6
+ require_relative "wrapper"
7
7
 
8
8
  module Console
9
9
  module Output
@@ -3,9 +3,9 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative '../format'
7
- require 'time'
8
- require 'fiber/annotation'
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 '../clock'
8
- require_relative '../terminal'
7
+ require_relative "../clock"
8
+ require_relative "../terminal"
9
9
 
10
- require 'json'
11
- require 'fiber'
12
- require 'fiber/annotation'
13
- require 'stringio'
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 = '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)
@@ -3,16 +3,16 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2021-2024, by Samuel Williams.
5
5
 
6
- require_relative 'output/default'
7
- require_relative 'output/serialized'
8
- require_relative 'output/terminal'
9
- require_relative 'output/null'
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['CONSOLE_OUTPUT']
15
- names = names.split(',').reverse
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)
@@ -4,7 +4,7 @@
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
  # Copyright, 2022, by Anton Sozontov.
6
6
 
7
- require_relative 'clock'
7
+ require_relative "clock"
8
8
 
9
9
  module Console
10
10
  class Progress
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2022, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
  # Copyright, 2021, by Robert Schulze.
6
6
 
7
- require_relative 'filter'
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['CONSOLE_OFF']&.split(',')
30
- on_klasses = env['CONSOLE_ON']&.split(',')
29
+ off_klasses = env["CONSOLE_OFF"]&.split(",")
30
+ on_klasses = env["CONSOLE_ON"]&.split(",")
31
31
 
32
32
  resolver = nil
33
33
 
@@ -3,7 +3,7 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require 'io/console'
6
+ require "io/console"
7
7
 
8
8
  module Console
9
9
  # Styled terminal output.
@@ -3,9 +3,9 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require 'io/console'
6
+ require "io/console"
7
7
 
8
- require_relative 'text'
8
+ require_relative "text"
9
9
 
10
10
  module Console
11
11
  # Styled terminal output.
@@ -3,12 +3,12 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'terminal/text'
7
- require_relative 'terminal/xterm'
6
+ require_relative "terminal/text"
7
+ require_relative "terminal/xterm"
8
8
 
9
- require_relative 'terminal/formatter/progress'
10
- require_relative 'terminal/formatter/failure'
11
- require_relative 'terminal/formatter/spawn'
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
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
6
  module Console
7
- VERSION = "1.27.0"
7
+ VERSION = "1.28.0"
8
8
  end
@@ -0,0 +1,31 @@
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
+ begin
22
+ fiber.console_warn = true
23
+ Console.warn(*arguments, **options)
24
+ ensure
25
+ fiber.console_warn = false
26
+ end
27
+ end
28
+ end
29
+
30
+ ::Kernel.prepend(Warn)
31
+ 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 'console/version'
10
- require_relative 'console/logger'
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,8 @@ 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
+
29
31
  ## Contributing
30
32
 
31
33
  We welcome contributions to this project.
data/releases.md ADDED
@@ -0,0 +1,5 @@
1
+ # Releases
2
+
3
+ ## v1.28.0
4
+
5
+ - 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.27.0
4
+ version: 1.28.0
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-07-18 00:00:00.000000000 Z
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
Binary file