console 1.26.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: ea53f121a472d6011335a91ac4a96f4f3630c4524b1158166be906a51e4dd186
4
- data.tar.gz: 20cdb45a16606315c9a0e054fb9e3460698e6fcccd190bd7668902f179c7b5fa
3
+ metadata.gz: cf762e4b31732049aa1f34fcc17bdb2430489efd671c74f435bfa214ef6290a5
4
+ data.tar.gz: 97ba24a40404eebfd1e2bf6544a673b5131628167ff82e7c933a05322ae5e0bf
5
5
  SHA512:
6
- metadata.gz: 42748b35f41a887222716d8bd0b9e55f92a5506f31fa7cb0a3e5ac5155341c55d6ca2849745b77d568b7b11e3d79faf0193377b9547fce98c5c16ca1043f9222
7
- data.tar.gz: de9535e3fb41fcce945512f9d482329cfc695888c43da753d1f7c392e074e4b4b1e6584fbfd1c39b4851c25f00563b1e0ee3efbd5240294649ff4dc68519483d
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
@@ -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 'generic'
8
+ require_relative "generic"
8
9
 
9
10
  module Console
10
11
  module Event
@@ -27,7 +28,9 @@ module Console
27
28
  def self.log(subject, exception, **options)
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
@@ -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,13 +3,13 @@
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
10
10
  class Sensitive < Wrapper
11
11
  REDACT = /
12
- phone
12
+ phone
13
13
  | email
14
14
  | full_?name
15
15
  | first_?name
@@ -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
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2024, by Samuel Williams.
4
+ # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
6
  module Console
7
7
  module Terminal
@@ -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.26.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/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,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.
@@ -38,14 +40,15 @@ We welcome contributions to this project.
38
40
 
39
41
  ### Developer Certificate of Origin
40
42
 
41
- This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
43
+ 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
44
 
43
- ### Contributor Covenant
45
+ ### Community Guidelines
44
46
 
45
- This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
47
+ 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
48
 
47
49
  ## See Also
48
50
 
49
51
  - [console-adapter-rails](https://github.com/socketry/console-adapter-rails)
50
52
  - [console-adapter-sidekiq](https://github.com/socketry/console-adapter-sidekiq)
51
53
  - [console-output-datadog](https://github.com/socketry/console-output-datadog)
54
+ - [sus-fixtures-console](https://github.com/sus-rb/sus-fixtures-console)
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.26.0
4
+ version: 1.28.0
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-07-17 00:00:00.000000000 Z
50
+ date: 2024-11-05 00:00:00.000000000 Z
50
51
  dependencies:
51
52
  - !ruby/object:Gem::Dependency
52
53
  name: fiber-annotation
@@ -127,8 +128,10 @@ files:
127
128
  - lib/console/terminal/text.rb
128
129
  - lib/console/terminal/xterm.rb
129
130
  - lib/console/version.rb
131
+ - lib/console/warn.rb
130
132
  - license.md
131
133
  - readme.md
134
+ - releases.md
132
135
  homepage: https://socketry.github.io/console
133
136
  licenses:
134
137
  - MIT
metadata.gz.sig CHANGED
Binary file