cogger 1.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20611cc2eeb6cbc938f208dd3076620f5dd99eba094502810c7092b2b686989a
4
- data.tar.gz: af57a2397409845990a3ffa547e958b1d5a255c477851ec1e394f0434d043f8f
3
+ metadata.gz: 1a8655e0aee27b95221e80234335e5c4850bf2b39729ab2f70c6ce817fe758bd
4
+ data.tar.gz: dcd69cd1c13ac6528851ac92a18facb31f4bf6b2056fb7ba8c7244669bf03744
5
5
  SHA512:
6
- metadata.gz: 5f9f99eb3d9954b42c1b05c10277afa2635c8632e295c0b884fe3da3923b0aa4ab418d9b7d9613ae01f55885e9b5bf00ae167315e1387fabb125cd96d4979a64
7
- data.tar.gz: 1a68c6a90c4a6edd03c014f6a9469a2be0a2bc565912943e34664904c2204088b4ce379a691bafaf9d6a06528904f45f9ea373bb683d3948ed5c9b0c06e163cc
6
+ metadata.gz: 51f1a9346fcb583164b34ce3d1e071ff75d4a134e3dfd491272c7368e4c145b53a0b3455aca50ee9a40c63b7ffa2163075ee856ddab519789fb78fdae24b8ca2
7
+ data.tar.gz: 319268287863d76706c2854fec96e4e8fd03ada640fc580ec4f99830133a1901b5cec7174b7b4dc1087f5e680a597822fef5a475c28be1f0dcd17b3de9c84bb2
checksums.yaml.gz.sig CHANGED
@@ -1 +1,2 @@
1
- =JP�3�!C�n����'6O!T�S�a�GD���(Q^}~�}Tr�IB��E�zz�`U��2.
1
+ r��'����YW��yr ��Ɓ)�p��&�}���}S���/DQ����?��L7��4(�(��"ۺ�
2
+ �Ƽ�%�x0�l~����Jܺ-:�7B�Hf���x�xoɽh]i
data/README.adoc CHANGED
@@ -114,8 +114,8 @@ When creating a new logger, you can configure behavior via the following attribu
114
114
  * `level`: The log level you want to log at. Can be `:debug`, `:info`, `:warn`, `:error`, `:fatal`, or `:unknown`. Default: `:info`.
115
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.%L%:z`.
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: `true`. This is automatically disabled -- and can't be overwritten -- when using the JSON formatter since the JSON format doesn't support code comments.
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, [2024-08-28T15:57:31.930722 #69391] INFO -- console: #<data Cogger::Entry id="console", level=:INFO, at=2024-08-28 15:57:31.930696 -0600, message="Demo", tags=[], datetime_format="%Y-%m-%dT%H:%M:%S.%L%:z", payload={}>
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 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:
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
- You can use `#abort` without a message which will not log anything and immediately exit:
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
- This is _not recommended_ since using `Kernel#exit` directly is more performant.
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.%L%:z\",
1216
+ # @datetime_format=\"%Y-%m-%dT%H:%M:%S%:z\",
1187
1217
  # @tags=[],
1188
- # @header=true,
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 = "1.7.0"
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 = ">= 3.4"
26
- spec.add_dependency "core", "~> 2.0"
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", "~> 13.5"
29
- spec.add_dependency "tone", "~> 2.0"
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*"]
@@ -30,7 +30,7 @@ module Cogger
30
30
  formatter: Formatters::Emoji.new,
31
31
  datetime_format: DATETIME_FORMAT,
32
32
  tags: Core::EMPTY_ARRAY,
33
- header: true,
33
+ header: false,
34
34
  mode: false,
35
35
  age: nil,
36
36
  size: 1_048_576,
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
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "pathname"
4
-
5
3
  # Computes default program name based on current file name.
6
4
  module Cogger
7
5
  Program = lambda do |name = $PROGRAM_NAME|
@@ -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
@@ -13,7 +13,7 @@ end
13
13
  module Cogger
14
14
  extend Registry
15
15
 
16
- DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%L%:z"
16
+ DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S%:z"
17
17
  LEVELS = %w[debug info warn error fatal unknown].freeze
18
18
 
19
19
  def self.loader registry = Zeitwerk::Registry
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: 1.7.0
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: '2.0'
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: '2.0'
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: '13.5'
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: '13.5'
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: '2.0'
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: '2.0'
93
+ version: '3.0'
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: zeitwerk
96
96
  requirement: !ruby/object:Gem::Requirement
@@ -168,14 +168,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
168
  requirements:
169
169
  - - ">="
170
170
  - !ruby/object:Gem::Version
171
- version: '3.4'
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: 3.7.2
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