cogger 2.1.0 → 2.3.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: a4069a3012f5099d0d04cb86b12bfee60f4b64237f9e1b89c29a51c24056fcc7
4
- data.tar.gz: e3da9703dba3a965bd9cd34d9c3f05e1577efc432753462611c0f97231a3249b
3
+ metadata.gz: 051cbeb63381e6680f86fd1b73a1e6648d6ecc1befc37824d0425cbb12d0fb63
4
+ data.tar.gz: 8772b28a29157d2f023096eaf40ba28c252888e3430e5ddc673ade49888b7da2
5
5
  SHA512:
6
- metadata.gz: 06454f1f032cdd9ff8e2e6d1461c18f3f7046f8c04024dfe15f4761359a38cfbecc35cc8e906c0d16b3eee6ef9efef5a4a6da2c9885cc9c73b1c5af6a50be1fa
7
- data.tar.gz: 75fdd9b6bef41be5436b0fbb4730d959291f08bea7de4cb67992d48b13540298d855a77ad5a0949cd59043d8cb5e405f7ecfd52a68e5e39484b98e0afe80ca75
6
+ metadata.gz: 4b290ebea636e3744c68dd07c1cd37bd310fa3c99600a8b7a32ed93dcdcc651559ff718fcfe43446c7bad91772ba25eb4bb60bfe0ff9f2c6f85d8158dc58c9c1
7
+ data.tar.gz: 163afc50ba9118ab76f2ff75f351b4d2b60992b29f317bbfab218e310ada42890fec1e5cfed6993bde0421d67126b65038adbe7b81791f062c07ae82e32c3143
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -182,7 +182,7 @@ export LOG_LEVEL=fatal
182
182
  export LOG_LEVEL=unknown
183
183
  ----
184
184
 
185
- While downcase is preferred for each log level value, you can use upcased values as well. If the `LOG_LEVEL` environment variable is not set, `Cogger` will fall back to `"info"` unless overwritten during initialization. Example: `Cogger.new level: :debug`. Otherwise, an invalid log level will result in an `ArgumentError`.
185
+ While lower case is preferred for each log level value, you can use upper case values as well. If the `LOG_LEVEL` environment variable is not set, `Cogger` will fall back to `"info"` unless overwritten during initialization. Example: `Cogger.new level: :debug`. Otherwise, an invalid log level will result in an `ArgumentError`.
186
186
 
187
187
  === Mutations
188
188
 
@@ -457,7 +457,7 @@ Additional keys as provided by your message hash and/or tags can be customized a
457
457
  Template keys, emojis, and elements do have a few restrictions:
458
458
 
459
459
  * Use the special `emoji` key to provide dynamic or specific emoji logging.
460
- * Use the special `tags` key to provide tagged logging. More information on tags can be found later in this document.
460
+ * Use the special `tags` key to provide tagged logging. For more information, the _Tags_ section below.
461
461
  * Avoid supplying the same keys as the default keys. Example: `logger.info id: :bad, at: Time.now, level: :bogus`. This is because these keys will be ignored. In other words, you can't _override_ the default keys.
462
462
  * Avoid wrapping keys and/or emojis in elements because nesting isn't supported and can lead to strange output. Example: `<green>%<emoji:error>s %<id:dynamic>s</green>`.
463
463
  * Avoid wrapping elements within elements because nesting isn't supported and can lead to strange output. Example: `<dynamic><cyan>%<message>s</cyan></dynamic>`.
@@ -757,8 +757,7 @@ logger.info "Demo", tags: ["WEB", "PRIMARY", {service: :api, demo: true}]
757
757
  # "level":"INFO",
758
758
  # "at":"2023-12-10T18:44:32.723+00:00",
759
759
  # "message":"Demo",
760
- # "tags":["WEB",
761
- # "PRIMARY"],
760
+ # "tags":["WEB", "PRIMARY"],
762
761
  # "service":"api",
763
762
  # "demo":true
764
763
  # }
@@ -929,6 +928,7 @@ As you can see, tags are highly versatile. That said, the following guidelines a
929
928
  * Prefer consistent tag names by using tags that are not synonymous or ambiguous.
930
929
  * Prefer using tags by feature rather than things like environments. Examples: API, DB, MAILER.
931
930
  * Prefer the JSON formatter for structured metadata instead of tags. Logging JSON formatted messages with tags will work but sticking with a traditional hash, instead of tags, will probably serve you better.
931
+ * Avoid using `id`, `level`, `at`, and/or `message` as hash keys since those are reserved keys and will be rejected if supplied.
932
932
 
933
933
  === Filters
934
934
 
@@ -970,14 +970,25 @@ You can add multiple log streams (outputs) by using:
970
970
 
971
971
  [source,ruby]
972
972
  ----
973
+ require "stringio"
974
+
975
+ buffer = StringIO.new
973
976
  logger = Cogger.new
977
+ .add_stream(io: buffer)
974
978
  .add_stream(io: "tmp/demo.log")
975
979
  .add_stream(io: nil)
976
980
 
977
981
  logger.info "Demo."
978
982
  ----
979
983
 
980
- The above would log the `"Demo."` message to `$stdout` -- the default stream -- to the `tmp/demo.log` file, and to `/dev/null`. All attributes used to construct your default logger apply to all additional streams unless customized further. This means any custom template/formatter can be applied to your streams. Example:
984
+ The above would log `"Demo."` to:
985
+
986
+ * To `$stdout` (the default stream which is your console).
987
+ * To the StringIO `buffer` where you can use `buffer.string` to view content.
988
+ * To the `tmp/demo.log` file where you can use `cat tmp/demo.log` to view content.
989
+ * To `/dev/null` which immediately ignores all writes.
990
+
991
+ All attributes used to construct your default logger apply to all additional streams unless customized further. This means any custom template/formatter can be applied to your streams. Example:
981
992
 
982
993
  [source,ruby]
983
994
  ----
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 = "2.1.0"
5
+ spec.version = "2.3.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/cogger"
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency "logger", "~> 1.7"
29
29
  spec.add_dependency "refinements", "~> 14.0"
30
30
  spec.add_dependency "tone", "~> 3.0"
31
- spec.add_dependency "zeitwerk", "~> 2.7"
31
+ spec.add_dependency "zeitwerk", "~> 2.8"
32
32
 
33
33
  spec.extra_rdoc_files = Dir["README*", "LICENSE*"]
34
34
  spec.files = Dir["*.gemspec", "lib/**/*"]
data/lib/cogger/tag.rb CHANGED
@@ -5,18 +5,24 @@ require "refinements/hash"
5
5
 
6
6
  module Cogger
7
7
  # Models a tag which may consist of an array and/or hash.
8
- Tag = Data.define :singles, :pairs do
8
+ Tag = Data.define :singles, :pairs, :exclusions do
9
9
  using Refinements::Hash
10
10
 
11
- def self.for(*bag)
12
- bag.each.with_object new do |item, tag|
11
+ def self.for(*bag) = new(**reduce(bag))
12
+
13
+ def self.reduce bag
14
+ bag.each.with_object({singles: [], pairs: {}}) do |item, all|
13
15
  value = item.is_a?(Proc) ? item.call : item
14
- value.is_a?(Hash) ? tag.pairs.merge!(value) : tag.singles.append(value)
16
+ value.is_a?(Hash) ? all[:pairs].merge!(value) : all[:singles].append(value)
15
17
  end
16
18
  end
17
19
 
18
- def initialize singles: [], pairs: {}
19
- super
20
+ private_class_method :reduce
21
+
22
+ def initialize singles: [], pairs: {}, exclusions: %w[id level at message]
23
+ filtered_pairs = pairs.reject { |key, _| exclusions.include? key.to_s }
24
+
25
+ super singles:, pairs: filtered_pairs, exclusions:
20
26
  end
21
27
 
22
28
  def empty? = singles.empty? && pairs.empty?
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: 2.1.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -9,9 +9,9 @@ bindir: bin
9
9
  cert_chain:
10
10
  - |
11
11
  -----BEGIN CERTIFICATE-----
12
- MIIENjCCAp6gAwIBAgIBAjANBgkqhkiG9w0BAQsFADBBMQ8wDQYDVQQDDAZicm9v
12
+ MIIENjCCAp6gAwIBAgIBAzANBgkqhkiG9w0BAQsFADBBMQ8wDQYDVQQDDAZicm9v
13
13
  a2UxGjAYBgoJkiaJk/IsZAEZFgphbGNoZW1pc3RzMRIwEAYKCZImiZPyLGQBGRYC
14
- aW8wHhcNMjUwMzIyMTQ1NDE3WhcNMjYwMzIyMTQ1NDE3WjBBMQ8wDQYDVQQDDAZi
14
+ aW8wHhcNMjYwMzI1MTI0OTEyWhcNMjcwMzI1MTI0OTEyWjBBMQ8wDQYDVQQDDAZ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G+ykjp+DIXSybGEtX+/ve974mYfN6
27
+ 8U7qcVfRM+qDSOZ+97iu30qUTbVAKIHlHCDKRn3SgOffDUB5VU2MsJBh/3TPKWBZ
28
+ anB/uzMcwOfru+qyA3b7ZFqZzRLWmR5FtPObFxc0gYMT3YvLNHk2Nb9Vjq/PoiGG
29
+ e75PXweDOokwDA5m1gMOz1rdp/dlGMXkSFQg94PPVyUKXgO4VzWTgePSDxOIL+v6
30
+ +OWV6AaEH9BaqxnmdA5ubi0L7bhl0gbN92FxpNO3kpTjww8kme856a+wCK3qyM5w
31
+ 7ZLbUexynDN0Au8eSpT2Bf6ztGmB1S9ffzDJsGX1/lkpMIB51e48Xe2+gzzOgemk
32
+ CdZaGupj6WkarnT8kh/cPtyA5ax4rGX6GOS8meGxzkv8Uy0JSEOYAp6wLfIisYZp
33
+ IJBIXIOkwKKJ0eB5YHrUSJxzpP4LlcIg/eTftaXmJdYjy+2VRrCZYDjfguyLmMjR
34
+ KR9w4/Fjvqy87kCHmxMWa6IL2Vzt1Clm2cA=
35
35
  -----END CERTIFICATE-----
36
36
  date: 1980-01-02 00:00:00.000000000 Z
37
37
  dependencies:
@@ -97,14 +97,14 @@ dependencies:
97
97
  requirements:
98
98
  - - "~>"
99
99
  - !ruby/object:Gem::Version
100
- version: '2.7'
100
+ version: '2.8'
101
101
  type: :runtime
102
102
  prerelease: false
103
103
  version_requirements: !ruby/object:Gem::Requirement
104
104
  requirements:
105
105
  - - "~>"
106
106
  - !ruby/object:Gem::Version
107
- version: '2.7'
107
+ version: '2.8'
108
108
  email:
109
109
  - brooke@alchemists.io
110
110
  executables: []
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  - !ruby/object:Gem::Version
176
176
  version: '0'
177
177
  requirements: []
178
- rubygems_version: 4.0.4
178
+ rubygems_version: 4.0.12
179
179
  specification_version: 4
180
180
  summary: A customizable and feature rich logger.
181
181
  test_files: []
metadata.gz.sig CHANGED
Binary file