cogger 1.6.0 → 2.0.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/README.adoc +41 -11
- data/cogger.gemspec +5 -5
- data/lib/cogger/configuration.rb +1 -1
- data/lib/cogger/hub.rb +5 -0
- data/lib/cogger/program.rb +0 -2
- data/lib/cogger/registry.rb +0 -16
- data/lib/cogger.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +10 -10
- 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: 1a8655e0aee27b95221e80234335e5c4850bf2b39729ab2f70c6ce817fe758bd
|
|
4
|
+
data.tar.gz: dcd69cd1c13ac6528851ac92a18facb31f4bf6b2056fb7ba8c7244669bf03744
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 51f1a9346fcb583164b34ce3d1e071ff75d4a134e3dfd491272c7368e4c145b53a0b3455aca50ee9a40c63b7ffa2163075ee856ddab519789fb78fdae24b8ca2
|
|
7
|
+
data.tar.gz: 319268287863d76706c2854fec96e4e8fd03ada640fc580ec4f99830133a1901b5cec7174b7b4dc1087f5e680a597822fef5a475c28be1f0dcd17b3de9c84bb2
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/README.adoc
CHANGED
|
@@ -112,10 +112,10 @@ When creating a new logger, you can configure behavior via the following attribu
|
|
|
112
112
|
* `id`: The program/process ID which shows up in the logs as your `id`. Default: `$PROGRAM_NAME`. For example, if run within a `demo.rb` script, the `id` would be `"demo"`,
|
|
113
113
|
* `io`: The input/output stream. This can be `STDOUT/$stdout`, a file/path, or `nil`. Default: `$stdout`.
|
|
114
114
|
* `level`: The log level you want to log at. Can be `:debug`, `:info`, `:warn`, `:error`, `:fatal`, or `:unknown`. Default: `:info`.
|
|
115
|
-
* `formatter`: The formatter to use for formatting your log output. Default: `Cogger::Formatter::
|
|
115
|
+
* `formatter`: The formatter to use for formatting your log output. Default: `Cogger::Formatter::Emoji`. See the _Formatters_ section for more info.
|
|
116
116
|
* `tags`: The global tags used for all log entries. _Must_ be an array of objects you wish to use for tagging purposes. Default: `[]`.
|
|
117
|
-
* `datetime_format`: The global date/time format used for all `Time`, `Date`, and/or `DateTime` values in your log entries. Default: `%Y-%m-%dT%H:%M:%S
|
|
118
|
-
* `header`: Determines if your log files should start with a date/time header comment. Can be `true` or `false` and is identical to the `skip_header` functionality found in the {logger_link} class. Default: `
|
|
117
|
+
* `datetime_format`: The global date/time format used for all `Time`, `Date`, and/or `DateTime` values in your log entries. Default: `%Y-%m-%dT%H:%M:%S%:z` ({rfc_3339_link}).
|
|
118
|
+
* `header`: Determines if your log files should start with a date/time header comment. Can be `true` or `false` and is identical to the `skip_header` functionality found in the {logger_link} class. Default: `false`. This is automatically disabled -- and can't be overwritten -- when using the JSON formatter since the JSON format doesn't support code comments.
|
|
119
119
|
* `mode`: The binary mode which determines if your logs should be written in binary mode or not. Can be `true` or `false` and is identical to the `binmode` functionality found in the {logger_link} class. Default: `false`.
|
|
120
120
|
* `age`: The rotation age of your log. This only applies when logging to a file. This is equivalent to the `shift_age` as found with the {logger_link} class. Default: `0`.
|
|
121
121
|
* `size`: The rotation size of your log. This only applies when logging to a file. This is equivalent to the `shift_size` as found with the {logger_link} class. Default: `1,048,576` (i.e. 1 MB).
|
|
@@ -158,8 +158,7 @@ The default date/time format used for _all_ log values can be viewed via the fol
|
|
|
158
158
|
|
|
159
159
|
[source,ruby]
|
|
160
160
|
----
|
|
161
|
-
Cogger::DATETIME_FORMAT
|
|
162
|
-
# "%Y-%m-%dT%H:%M:%S.%L%:z
|
|
161
|
+
Cogger::DATETIME_FORMAT # "%Y-%m-%dT%H:%M:%S%:z"
|
|
163
162
|
----
|
|
164
163
|
|
|
165
164
|
The above adheres to {rfc_3339_link} and can be customized -- as mentioned earlier -- when creating a new logger instance. Example:
|
|
@@ -822,7 +821,7 @@ require "logger"
|
|
|
822
821
|
logger = Cogger.new formatter: Logger::Formatter.new
|
|
823
822
|
logger.info "Demo"
|
|
824
823
|
|
|
825
|
-
# I, [
|
|
824
|
+
# I, [2025-12-27T14:31:23.865252 #29621] INFO -- console: #<data Cogger::Entry id="console", level=:INFO, at=2025-12-27 14:31:23.865216 -0700, message="Demo", tags=[], datetime_format="%Y-%m-%dT%H:%M:%S%:z", payload={}>
|
|
826
825
|
----
|
|
827
826
|
|
|
828
827
|
While the above doesn't cause an error, you only get a dump of the `Cogger::Entry` which is not what you want. To replicate native {logger_link} functionality, you can use the `Simple` formatter as follows:
|
|
@@ -1009,7 +1008,7 @@ logger.info "Demo"
|
|
|
1009
1008
|
|
|
1010
1009
|
=== Abort
|
|
1011
1010
|
|
|
1012
|
-
Aborting a program is
|
|
1011
|
+
Aborting a program is syntactic sugar for Command Line Interfaces (CLIs) 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:
|
|
1013
1012
|
|
|
1014
1013
|
[source,ruby]
|
|
1015
1014
|
----
|
|
@@ -1028,7 +1027,7 @@ logger.abort message: "Danger!"
|
|
|
1028
1027
|
# Exits with status code: 1.
|
|
1029
1028
|
----
|
|
1030
1029
|
|
|
1031
|
-
|
|
1030
|
+
Please _avoid_ using `#abort` without a message. Example:
|
|
1032
1031
|
|
|
1033
1032
|
[source,ruby]
|
|
1034
1033
|
----
|
|
@@ -1036,7 +1035,38 @@ logger.abort
|
|
|
1036
1035
|
# Logs no message and exits with status code: 1.
|
|
1037
1036
|
----
|
|
1038
1037
|
|
|
1039
|
-
|
|
1038
|
+
Use `Kernel#exit` instead since it's more performant.
|
|
1039
|
+
|
|
1040
|
+
=== Panic
|
|
1041
|
+
|
|
1042
|
+
This is syntactic sugar for Command Line Interfaces (CLIs) where you need to log a fatal message _and_ exit the program at the same time with an exit code of `1`. This allows your CLI to log a message and ensure the exit status is correct when displaying status, piping commands together, etc. All of the arguments, when messaging `#fatal` directly, are the same. Example:
|
|
1043
|
+
|
|
1044
|
+
[source,ruby]
|
|
1045
|
+
----
|
|
1046
|
+
logger = Cogger.new
|
|
1047
|
+
|
|
1048
|
+
logger.panic "Danger!"
|
|
1049
|
+
# 🔥 [console] Danger!
|
|
1050
|
+
# Exits with status code: 1.
|
|
1051
|
+
|
|
1052
|
+
logger.panic { "Danger!" }
|
|
1053
|
+
# 🔥 [console] Danger!
|
|
1054
|
+
# Exits with status code: 1.
|
|
1055
|
+
|
|
1056
|
+
logger.panic message: "Danger!"
|
|
1057
|
+
# 🔥 [console] Danger!
|
|
1058
|
+
# Exits with status code: 1.
|
|
1059
|
+
----
|
|
1060
|
+
|
|
1061
|
+
Please _avoid_ using `#panic` without a message. Example:
|
|
1062
|
+
|
|
1063
|
+
[source,ruby]
|
|
1064
|
+
----
|
|
1065
|
+
logger.panic
|
|
1066
|
+
# Logs no message and exits with status code: 1.
|
|
1067
|
+
----
|
|
1068
|
+
|
|
1069
|
+
Use `Kernel#exit` instead since it's more performant.
|
|
1040
1070
|
|
|
1041
1071
|
=== Rack
|
|
1042
1072
|
|
|
@@ -1183,9 +1213,9 @@ logger.inspect
|
|
|
1183
1213
|
# @io=IO,
|
|
1184
1214
|
# @level=1,
|
|
1185
1215
|
# @formatter=Cogger::Formatters::Emoji,
|
|
1186
|
-
# @datetime_format=\"%Y-%m-%dT%H:%M:%S
|
|
1216
|
+
# @datetime_format=\"%Y-%m-%dT%H:%M:%S%:z\",
|
|
1187
1217
|
# @tags=[],
|
|
1188
|
-
# @header=
|
|
1218
|
+
# @header=false,
|
|
1189
1219
|
# @mode=false,
|
|
1190
1220
|
# @age=,
|
|
1191
1221
|
# @size=1048576,
|
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 = "
|
|
5
|
+
spec.version = "2.0.0"
|
|
6
6
|
spec.authors = ["Brooke Kuhlmann"]
|
|
7
7
|
spec.email = ["brooke@alchemists.io"]
|
|
8
8
|
spec.homepage = "https://alchemists.io/projects/cogger"
|
|
@@ -22,11 +22,11 @@ Gem::Specification.new do |spec|
|
|
|
22
22
|
spec.signing_key = Gem.default_key_path
|
|
23
23
|
spec.cert_chain = [Gem.default_cert_path]
|
|
24
24
|
|
|
25
|
-
spec.required_ruby_version = "
|
|
26
|
-
spec.add_dependency "core", "~>
|
|
25
|
+
spec.required_ruby_version = ">= 4.0"
|
|
26
|
+
spec.add_dependency "core", "~> 3.0"
|
|
27
27
|
spec.add_dependency "logger", "~> 1.7"
|
|
28
|
-
spec.add_dependency "refinements", "~>
|
|
29
|
-
spec.add_dependency "tone", "~>
|
|
28
|
+
spec.add_dependency "refinements", "~> 14.0"
|
|
29
|
+
spec.add_dependency "tone", "~> 3.0"
|
|
30
30
|
spec.add_dependency "zeitwerk", "~> 2.7"
|
|
31
31
|
|
|
32
32
|
spec.extra_rdoc_files = Dir["README*", "LICENSE*"]
|
data/lib/cogger/configuration.rb
CHANGED
data/lib/cogger/hub.rb
CHANGED
|
@@ -64,6 +64,11 @@ module Cogger
|
|
|
64
64
|
exit false
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
+
def panic(message = nil, **payload, &block)
|
|
68
|
+
fatal(message, **payload, &block) if message || !payload.empty? || block
|
|
69
|
+
exit false
|
|
70
|
+
end
|
|
71
|
+
|
|
67
72
|
def add(level, message = nil, **, &)
|
|
68
73
|
log(Logger::SEV_LABEL.fetch(level, "ANY").downcase, message, **, &)
|
|
69
74
|
end
|
data/lib/cogger/program.rb
CHANGED
data/lib/cogger/registry.rb
CHANGED
|
@@ -46,14 +46,6 @@ module Cogger
|
|
|
46
46
|
|
|
47
47
|
def aliases = color.aliases
|
|
48
48
|
|
|
49
|
-
def add_emoji key, value
|
|
50
|
-
warn "`#{self.class}##{__method__}` is deprecated, use `#add_emojis` instead.",
|
|
51
|
-
category: :deprecated
|
|
52
|
-
|
|
53
|
-
emojis[key.to_sym] = value
|
|
54
|
-
self
|
|
55
|
-
end
|
|
56
|
-
|
|
57
49
|
def add_emojis(**attributes)
|
|
58
50
|
emojis.merge! attributes.symbolize_keys!
|
|
59
51
|
self
|
|
@@ -65,14 +57,6 @@ module Cogger
|
|
|
65
57
|
|
|
66
58
|
def emojis = @emojis ||= {}
|
|
67
59
|
|
|
68
|
-
def add_filter key
|
|
69
|
-
warn "`#{self.class}##{__method__}` is deprecated, use `#add_filters` instead.",
|
|
70
|
-
category: :deprecated
|
|
71
|
-
|
|
72
|
-
filters.add key.to_sym
|
|
73
|
-
self
|
|
74
|
-
end
|
|
75
|
-
|
|
76
60
|
def add_filters(*keys)
|
|
77
61
|
filters.merge(keys.map(&:to_sym))
|
|
78
62
|
self
|
data/lib/cogger.rb
CHANGED
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:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brooke Kuhlmann
|
|
@@ -41,14 +41,14 @@ dependencies:
|
|
|
41
41
|
requirements:
|
|
42
42
|
- - "~>"
|
|
43
43
|
- !ruby/object:Gem::Version
|
|
44
|
-
version: '
|
|
44
|
+
version: '3.0'
|
|
45
45
|
type: :runtime
|
|
46
46
|
prerelease: false
|
|
47
47
|
version_requirements: !ruby/object:Gem::Requirement
|
|
48
48
|
requirements:
|
|
49
49
|
- - "~>"
|
|
50
50
|
- !ruby/object:Gem::Version
|
|
51
|
-
version: '
|
|
51
|
+
version: '3.0'
|
|
52
52
|
- !ruby/object:Gem::Dependency
|
|
53
53
|
name: logger
|
|
54
54
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -69,28 +69,28 @@ dependencies:
|
|
|
69
69
|
requirements:
|
|
70
70
|
- - "~>"
|
|
71
71
|
- !ruby/object:Gem::Version
|
|
72
|
-
version: '
|
|
72
|
+
version: '14.0'
|
|
73
73
|
type: :runtime
|
|
74
74
|
prerelease: false
|
|
75
75
|
version_requirements: !ruby/object:Gem::Requirement
|
|
76
76
|
requirements:
|
|
77
77
|
- - "~>"
|
|
78
78
|
- !ruby/object:Gem::Version
|
|
79
|
-
version: '
|
|
79
|
+
version: '14.0'
|
|
80
80
|
- !ruby/object:Gem::Dependency
|
|
81
81
|
name: tone
|
|
82
82
|
requirement: !ruby/object:Gem::Requirement
|
|
83
83
|
requirements:
|
|
84
84
|
- - "~>"
|
|
85
85
|
- !ruby/object:Gem::Version
|
|
86
|
-
version: '
|
|
86
|
+
version: '3.0'
|
|
87
87
|
type: :runtime
|
|
88
88
|
prerelease: false
|
|
89
89
|
version_requirements: !ruby/object:Gem::Requirement
|
|
90
90
|
requirements:
|
|
91
91
|
- - "~>"
|
|
92
92
|
- !ruby/object:Gem::Version
|
|
93
|
-
version: '
|
|
93
|
+
version: '3.0'
|
|
94
94
|
- !ruby/object:Gem::Dependency
|
|
95
95
|
name: zeitwerk
|
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -166,16 +166,16 @@ require_paths:
|
|
|
166
166
|
- lib
|
|
167
167
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
168
168
|
requirements:
|
|
169
|
-
- - "
|
|
169
|
+
- - ">="
|
|
170
170
|
- !ruby/object:Gem::Version
|
|
171
|
-
version: '
|
|
171
|
+
version: '4.0'
|
|
172
172
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
173
|
requirements:
|
|
174
174
|
- - ">="
|
|
175
175
|
- !ruby/object:Gem::Version
|
|
176
176
|
version: '0'
|
|
177
177
|
requirements: []
|
|
178
|
-
rubygems_version:
|
|
178
|
+
rubygems_version: 4.0.3
|
|
179
179
|
specification_version: 4
|
|
180
180
|
summary: A customizable and feature rich logger.
|
|
181
181
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|