cogger 0.15.0 → 0.16.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: 06b02f31842765991c8645f435efe1ac2c8d2ad54ec52e04cbfe6fc64096dd6d
4
- data.tar.gz: 819a9aa91290741d08ea935c8ae9046676a6255c940759d6b4dd0eca5820f0f5
3
+ metadata.gz: 6cc72e287de4da7142df1dc928db707a3f80f2d9f149319b6c56fef0ba18abe4
4
+ data.tar.gz: 7740a2b7996fe62802224f027bcd046ec2a678631f8c4c50a614d3544e00fa75
5
5
  SHA512:
6
- metadata.gz: 2a6973639d6f83b05959cfc596d0940ed80e733c24df781a973b479a9bc406d8ab5fee499cc24dd6c9eaf9aabef59a6b2f7474eeab7012ceeb96390b518c1ad7
7
- data.tar.gz: 9209e5c53220d33beb9f72c56c22b8bbbe5b731dc0ea25b6fdbca1955f7317619bfa35bf8a00a5e8eca178e9c95b770ce948d83392df43e7f5d60f23f1b4413a
6
+ metadata.gz: deb27d680a13bea905d22973a05349ff4e96d79d8e9c705d5e6af5d9604ed392ce2a08587cb1a401b6e9714f257e45ba1ff1c64d432e61cd893ce143eb3ddc3f
7
+ data.tar.gz: c0d52748459efb13ac0a0ec7d9b1fb52acf1d4eb63bc8f35ffafe8c542e7eace0e64f852c324dfcf8f9b83a8eba8a228504ac9c7672426b9f0f5377e5023d14a
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -755,6 +755,31 @@ logger.info "Demo"
755
755
  # Demo
756
756
  ----
757
757
 
758
+ === Abort
759
+
760
+ Aborting a program is mostly syntax sugar for Command Line Interfaces (CLIs) which aids in situations where you need to log an error message _and_ exit the program at the same time with an exit code of `1` (similar to how `Kernel#abort` behaves). This allows your CLI to log an error and ensure the exit status is correct when displaying status, piping commands together, etc. All of the arguments, when messaging `#error` directly, are the same. Here's how it works:
761
+
762
+ [source,ruby]
763
+ ----
764
+ logger = Cogger.new
765
+
766
+ # Not recommended since `Kernel#exit false` is faster.
767
+ logger.abort
768
+ # Logs no message and exits with status code: 1.
769
+
770
+ logger.abort "Danger!"
771
+ # 🛑 Danger!
772
+ # Exits with status code: 1.
773
+
774
+ logger.abort { "Danger!" }
775
+ # 🛑 Danger!
776
+ # Exits with status code: 1.
777
+
778
+ logger.abort message: "Danger!"
779
+ # 🛑 Danger!
780
+ # Exits with status code: 1.
781
+ ----
782
+
758
783
  === Rack
759
784
 
760
785
  {rack_link} is _implicitly_ supported which means your middleware _must be_ Rack-based and _must require_ the Rack gem since `Cogger::Rack::Logger` doesn't _explicitly_ require Rack by default. If these requirements are met then, to add HTTP request logging, you only need to use it. Example:
data/cogger.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "cogger"
5
- spec.version = "0.15.0"
5
+ spec.version = "0.16.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/cogger"
data/lib/cogger/hub.rb CHANGED
@@ -8,6 +8,7 @@ require "refinements/logger"
8
8
  module Cogger
9
9
  # Loads configuration and simultaneously sends messages to multiple streams.
10
10
  # :reek:TooManyInstanceVariables
11
+ # :reek:TooManyMethods
11
12
  class Hub
12
13
  extend Forwardable
13
14
 
@@ -49,20 +50,25 @@ module Cogger
49
50
  self
50
51
  end
51
52
 
52
- def debug(message = nil, **payload, &) = log(__method__, message, **payload, &)
53
+ def debug(message = nil, **, &) = log(__method__, message, **, &)
53
54
 
54
- def info(message = nil, **payload, &) = log(__method__, message, **payload, &)
55
+ def info(message = nil, **, &) = log(__method__, message, **, &)
55
56
 
56
- def warn(message = nil, **payload, &) = log(__method__, message, **payload, &)
57
+ def warn(message = nil, **, &) = log(__method__, message, **, &)
57
58
 
58
- def error(message = nil, **payload, &) = log(__method__, message, **payload, &)
59
+ def error(message = nil, **, &) = log(__method__, message, **, &)
59
60
 
60
- def fatal(message = nil, **payload, &) = log(__method__, message, **payload, &)
61
+ def fatal(message = nil, **, &) = log(__method__, message, **, &)
61
62
 
62
- def any(message = nil, **payload, &) = log(__method__, message, **payload, &)
63
+ def any(message = nil, **, &) = log(__method__, message, **, &)
63
64
 
64
- def add(severity, message = nil, **payload, &)
65
- log(Logger::SEV_LABEL.fetch(severity, "ANY").downcase, message, **payload, &)
65
+ def abort(message = nil, **payload, &block)
66
+ error(message, **payload, &block) if message || !payload.empty? || block
67
+ exit false
68
+ end
69
+
70
+ def add(severity, message = nil, **, &)
71
+ log(Logger::SEV_LABEL.fetch(severity, "ANY").downcase, message, **, &)
66
72
  end
67
73
 
68
74
  alias unknown any
@@ -88,8 +94,8 @@ module Cogger
88
94
  )
89
95
  end
90
96
 
91
- def log(severity, message = nil, **payload, &)
92
- dispatch(severity, message, **payload, &)
97
+ def log(severity, message = nil, **, &)
98
+ dispatch(severity, message, **, &)
93
99
  rescue StandardError => error
94
100
  crash message, error
95
101
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cogger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -35,7 +35,7 @@ cert_chain:
35
35
  3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
36
36
  gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
37
37
  -----END CERTIFICATE-----
38
- date: 2024-01-01 00:00:00.000000000 Z
38
+ date: 2024-01-13 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: core
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
155
  - !ruby/object:Gem::Version
156
156
  version: '0'
157
157
  requirements: []
158
- rubygems_version: 3.5.3
158
+ rubygems_version: 3.5.4
159
159
  signing_key:
160
160
  specification_version: 4
161
161
  summary: A customizable and feature rich logger.
metadata.gz.sig CHANGED
Binary file