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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.adoc +25 -0
- data/cogger.gemspec +1 -1
- data/lib/cogger/hub.rb +16 -10
- data.tar.gz.sig +0 -0
- metadata +3 -3
- 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: 6cc72e287de4da7142df1dc928db707a3f80f2d9f149319b6c56fef0ba18abe4
|
4
|
+
data.tar.gz: 7740a2b7996fe62802224f027bcd046ec2a678631f8c4c50a614d3544e00fa75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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,
|
53
|
+
def debug(message = nil, **, &) = log(__method__, message, **, &)
|
53
54
|
|
54
|
-
def info(message = nil,
|
55
|
+
def info(message = nil, **, &) = log(__method__, message, **, &)
|
55
56
|
|
56
|
-
def warn(message = nil,
|
57
|
+
def warn(message = nil, **, &) = log(__method__, message, **, &)
|
57
58
|
|
58
|
-
def error(message = nil,
|
59
|
+
def error(message = nil, **, &) = log(__method__, message, **, &)
|
59
60
|
|
60
|
-
def fatal(message = nil,
|
61
|
+
def fatal(message = nil, **, &) = log(__method__, message, **, &)
|
61
62
|
|
62
|
-
def any(message = nil,
|
63
|
+
def any(message = nil, **, &) = log(__method__, message, **, &)
|
63
64
|
|
64
|
-
def
|
65
|
-
|
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,
|
92
|
-
dispatch(severity, message,
|
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.
|
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-
|
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.
|
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
|