cogger 0.12.0 → 0.13.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 +153 -49
- data/cogger.gemspec +2 -1
- data/lib/cogger/configuration.rb +2 -1
- data/lib/cogger/entry.rb +4 -2
- data/lib/cogger/formatters/json.rb +6 -2
- data/lib/cogger/formatters/parsers/universal.rb +3 -1
- data/lib/cogger/hub.rb +7 -1
- data/lib/cogger/registry.rb +0 -3
- data/lib/cogger/tag.rb +7 -7
- data.tar.gz.sig +0 -0
- metadata +17 -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: 57f5049812c9af7fd2f1f936ac37c85562fad47517f6b3d2ccd2e34e2d1ee691
|
4
|
+
data.tar.gz: 2ecc0b1bd9e9cc37c85ee9f8db19c936b47d65a71b4723631f96debcdbd4b23e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4318c120bb3182a8a0740025b1528a6643b876b3d0ff71e3b875304484b4da5df44af044d474e2d93cacd1807487560063ac5e4d8499ef514a42c1c5644573a6
|
7
|
+
data.tar.gz: 7018412ed2a90da5e9fc31931e203d76767f405ff1559644570382891ccdb412c19c30eb2bb86f56f52be4e624f2938decb8f00c5fbf50feaf11735cf2e9f8bc
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -28,27 +28,27 @@ toc::[]
|
|
28
28
|
|
29
29
|
*Emoji*
|
30
30
|
|
31
|
-
image::https://alchemists.io/images/projects/cogger/screenshots/emoji.png[Emoji,width=
|
31
|
+
image::https://alchemists.io/images/projects/cogger/screenshots/emoji.png[Emoji,width=234,height=293]
|
32
32
|
|
33
33
|
*Color*
|
34
34
|
|
35
|
-
image::https://alchemists.io/images/projects/cogger/screenshots/color.png[Color,width=
|
35
|
+
image::https://alchemists.io/images/projects/cogger/screenshots/color.png[Color,width=202,height=288]
|
36
36
|
|
37
37
|
*Simple*
|
38
38
|
|
39
|
-
image::https://alchemists.io/images/projects/cogger/screenshots/simple.png[Simple,width=
|
39
|
+
image::https://alchemists.io/images/projects/cogger/screenshots/simple.png[Simple,width=288,height=253]
|
40
40
|
|
41
41
|
*Detail*
|
42
42
|
|
43
|
-
image::https://alchemists.io/images/projects/cogger/screenshots/detail.png[Detail,width=
|
43
|
+
image::https://alchemists.io/images/projects/cogger/screenshots/detail.png[Detail,width=611,height=284]
|
44
44
|
|
45
45
|
*JSON*
|
46
46
|
|
47
|
-
image::https://alchemists.io/images/projects/cogger/screenshots/json.png[JSON,width=
|
47
|
+
image::https://alchemists.io/images/projects/cogger/screenshots/json.png[JSON,width=962,height=297]
|
48
48
|
|
49
49
|
*Rack*
|
50
50
|
|
51
|
-
image::https://alchemists.io/images/projects/cogger/screenshots/rack.png[Rack,width=
|
51
|
+
image::https://alchemists.io/images/projects/cogger/screenshots/rack.png[Rack,width=883,height=282]
|
52
52
|
|
53
53
|
== Requirements
|
54
54
|
|
@@ -93,7 +93,7 @@ All interaction is provided by `Cogger` which can be used as follows:
|
|
93
93
|
[source,ruby]
|
94
94
|
----
|
95
95
|
logger = Cogger.new
|
96
|
-
logger.info "
|
96
|
+
logger.info "Demo" # "Demo"
|
97
97
|
----
|
98
98
|
|
99
99
|
If you set your logging level to `debug`, you can walk through each level:
|
@@ -103,22 +103,24 @@ If you set your logging level to `debug`, you can walk through each level:
|
|
103
103
|
logger = Cogger.new level: :debug
|
104
104
|
|
105
105
|
# Without blocks.
|
106
|
-
logger.debug "
|
107
|
-
logger.info "
|
108
|
-
logger.warn "
|
109
|
-
logger.error "
|
110
|
-
logger.fatal "
|
111
|
-
logger.unknown "
|
112
|
-
logger.any "
|
106
|
+
logger.debug "Demo" # "🔎 Demo"
|
107
|
+
logger.info "Demo" # "🟢 Demo"
|
108
|
+
logger.warn "Demo" # "⚠️ Demo"
|
109
|
+
logger.error "Demo" # "🛑 Demo"
|
110
|
+
logger.fatal "Demo" # "🔥 Demo"
|
111
|
+
logger.unknown "Demo" # "⚫️ Demo"
|
112
|
+
logger.any "Demo" # "⚫️ Demo"
|
113
|
+
logger.add Logger::INFO, "Demo" # "🟢 Demo"
|
113
114
|
|
114
115
|
# With blocks.
|
115
|
-
logger.debug { "
|
116
|
-
logger.info { "
|
117
|
-
logger.warn { "
|
118
|
-
logger.error { "
|
119
|
-
logger.fatal { "
|
120
|
-
logger.unknown { "
|
121
|
-
logger.any { "
|
116
|
+
logger.debug { "Demo" } # "🔎 Demo"
|
117
|
+
logger.info { "Demo" } # "🟢 Demo"
|
118
|
+
logger.warn { "Demo" } # "⚠️ Demo"
|
119
|
+
logger.error { "Demo" } # "🛑 Demo"
|
120
|
+
logger.fatal { "Demo" } # "🔥 Demo"
|
121
|
+
logger.unknown { "Demo" } # "⚫️ Demo"
|
122
|
+
logger.any { "Demo" } # "⚫️ Demo"
|
123
|
+
logger.add(Logger::INFO) { "Demo" } # "🟢 Demo"
|
122
124
|
----
|
123
125
|
|
124
126
|
=== Initialization
|
@@ -154,6 +156,72 @@ logger = Cogger.new id: :demo,
|
|
154
156
|
suffix: "%Y"
|
155
157
|
----
|
156
158
|
|
159
|
+
=== Inspection
|
160
|
+
|
161
|
+
Each instance can be inspected via the `#inspect` message:
|
162
|
+
|
163
|
+
[source,ruby]
|
164
|
+
----
|
165
|
+
logger = Cogger.new
|
166
|
+
logger.inspect
|
167
|
+
|
168
|
+
# "#<Cogger::Hub @id=console,
|
169
|
+
# @io=IO,
|
170
|
+
# @level=1,
|
171
|
+
# @formatter=Cogger::Formatters::Emoji,
|
172
|
+
# @tags=[],
|
173
|
+
# @mode=false,
|
174
|
+
# @age=0,
|
175
|
+
# @size=1048576,
|
176
|
+
# @suffix=\"%Y-%m-%d\",
|
177
|
+
# @entry=Cogger::Entry,
|
178
|
+
# @logger=Logger>"
|
179
|
+
----
|
180
|
+
|
181
|
+
You can also look at individual attributes:
|
182
|
+
|
183
|
+
[source,ruby]
|
184
|
+
----
|
185
|
+
logger = Cogger.new
|
186
|
+
|
187
|
+
logger.id # "console"
|
188
|
+
logger.io # #<IO:<STDOUT>>
|
189
|
+
logger.tags # []
|
190
|
+
logger.mode # false
|
191
|
+
logger.age # 0
|
192
|
+
logger.size # 1048576
|
193
|
+
logger.suffix # "%Y-%m-%d"
|
194
|
+
|
195
|
+
logger.level # 1
|
196
|
+
logger.formatter # Cogger::Formatters::Emoji
|
197
|
+
logger.debug? # false
|
198
|
+
logger.info? # true
|
199
|
+
logger.warn? # true
|
200
|
+
logger.error? # true
|
201
|
+
logger.fatal? # true
|
202
|
+
----
|
203
|
+
|
204
|
+
=== Mutations
|
205
|
+
|
206
|
+
Each instance can be mutated using the following messages:
|
207
|
+
|
208
|
+
[source,ruby]
|
209
|
+
----
|
210
|
+
logger = Cogger.new io: StringIO.new
|
211
|
+
|
212
|
+
logger.close # nil
|
213
|
+
logger.reopen # Logger
|
214
|
+
logger.debug! # 0
|
215
|
+
logger.info! # 1
|
216
|
+
logger.warn! # 2
|
217
|
+
logger.error! # 3
|
218
|
+
logger.fatal! # 4
|
219
|
+
logger.formatter = Cogger::Formatters::Simple.new # Cogger::Formatters::Simple
|
220
|
+
logger.level = Logger::WARN # 2
|
221
|
+
----
|
222
|
+
|
223
|
+
Please see the {logger_link} documentation for more information.
|
224
|
+
|
157
225
|
=== Environment
|
158
226
|
|
159
227
|
The default log level is `INFO` but can be customized via your environment. For instance, you could
|
@@ -361,8 +429,10 @@ Symbols or strings can be used interchangeably when adding/getting formatters. A
|
|
361
429
|
|
362
430
|
[source,ruby]
|
363
431
|
----
|
364
|
-
Cogger::Formatters::
|
365
|
-
# "%<message>s"
|
432
|
+
Cogger::Formatters::Color::TEMPLATE # "%<message:dynamic>s"
|
433
|
+
Cogger::Formatters::Emoji::TEMPLATE # "%<emoji:dynamic>s %<message:dynamic>s"
|
434
|
+
Cogger::Formatters::JSON::TEMPLATE # nil
|
435
|
+
Cogger::Formatters::Simple::TEMPLATE # "%<message>s"
|
366
436
|
----
|
367
437
|
|
368
438
|
💡 When you find yourself customizing any of the default formatters, you can reduce typing by adding your custom configuration to the registry and then referring to it via it's associated key when initializing a new logger.
|
@@ -469,17 +539,22 @@ logger.warn "Demo"
|
|
469
539
|
|
470
540
|
==== JSON
|
471
541
|
|
472
|
-
This formatter is similar in behavior to the _simple_ formatter except the template allows you to _order_ the layout of your keys. All other information is ignored.
|
542
|
+
This formatter is similar in behavior to the _simple_ formatter except the template allows you to _order_ the layout of your keys. All other template information is ignored, only the order of your template keys matters. Example:
|
543
|
+
|
544
|
+
*Default Order*
|
473
545
|
|
474
546
|
[source,ruby]
|
475
547
|
----
|
476
|
-
# Default order
|
477
548
|
logger = Cogger.new formatter: :json
|
478
549
|
logger.info verb: "GET", path: "/"
|
479
550
|
|
480
551
|
# {"id":"console","severity":"INFO","at":"2023-04-10 09:03:55 -0600","verb":"GET","path":"/"}
|
552
|
+
----
|
553
|
+
|
554
|
+
*Custom Order*
|
481
555
|
|
482
|
-
|
556
|
+
[source,ruby]
|
557
|
+
----
|
483
558
|
logger = Cogger.new formatter: Cogger::Formatters::JSON.new("%<severity>s %<verb>s")
|
484
559
|
logger.info verb: "GET", path: "/"
|
485
560
|
|
@@ -488,9 +563,43 @@ logger.info verb: "GET", path: "/"
|
|
488
563
|
|
489
564
|
Your template can be a full or partial match of keys. If no keys match what is defined in the template, then the original order of the keys will be used instead.
|
490
565
|
|
566
|
+
You can always supply a message as your first argument -- or specify it by using the `:message` key -- but is removed if not supplied which is why the above doesn't print a message in the output. To illustrate, the following are equivalent:
|
567
|
+
|
568
|
+
[source,ruby]
|
569
|
+
----
|
570
|
+
logger = Cogger.new formatter: json
|
571
|
+
|
572
|
+
logger.info "Demo"
|
573
|
+
# {"id":"console","severity":"INFO","at":"2023-10-18 19:38:55 -0600","message":"Demo"}
|
574
|
+
|
575
|
+
logger.info messsage: "Demo"
|
576
|
+
{"id":"console","severity":"INFO","at":"2023-10-18 19:39:19 -0600","messsage":"Demo"}
|
577
|
+
----
|
578
|
+
|
579
|
+
When tags are provided, the `:tags` key will appear in the output depending on whether you are using _single tags_. If hash tags are used, they'll show up as additional attributes in the outout. Here's an example where a mix of single and hash keys are used:
|
580
|
+
|
581
|
+
[source,ruby]
|
582
|
+
----
|
583
|
+
logger = Cogger.new formatter: :json
|
584
|
+
|
585
|
+
logger.info "Demo", tags: ["WEB", "PRIMARY", {service: :api, demo: true}]
|
586
|
+
|
587
|
+
# {
|
588
|
+
# "id":"console",
|
589
|
+
# "severity":"INFO",
|
590
|
+
# "at":"2023-10-18 19:47:11 -0600",
|
591
|
+
# "message":"Demo",
|
592
|
+
# "tags":["WEB","PRIMARY"],
|
593
|
+
# "service":"api",
|
594
|
+
# "demo":true
|
595
|
+
# }
|
596
|
+
----
|
597
|
+
|
598
|
+
Notice, with the above, that the single tags of `WEB` and `PRIMARY` show up in the `tags` array while the `:service` and `:demo` keys show up at the top level of the hash. Since the `:tags`, `:service`, `:demo` keys are normal keys, like any key in your JSON output, this means you can use a custom template to arrange the order of these keys if you don't like the default.
|
599
|
+
|
491
600
|
==== Native
|
492
601
|
|
493
|
-
Should you wish to use the native formatter as provided by original/native {logger_link}, it will work but not in the manner
|
602
|
+
Should you wish to use the native formatter as provided by original/native {logger_link}, it will work but not in the manner you might expect. Example:
|
494
603
|
|
495
604
|
[source,ruby]
|
496
605
|
----
|
@@ -569,10 +678,10 @@ You are not limited to string-based tags. Any object will work:
|
|
569
678
|
logger = Cogger.new tags: ["ONE", :two, 3, {four: "FOUR"}, proc { "FIVE" }]
|
570
679
|
logger.info "Demo"
|
571
680
|
|
572
|
-
🟢 [ONE] [two] [3] [FIVE] [four=FOUR] Demo
|
681
|
+
# 🟢 [ONE] [two] [3] [FIVE] [four=FOUR] Demo
|
573
682
|
----
|
574
683
|
|
575
|
-
With the above, we have string, symbol, integer, hash, and proc tags. With hashes, you'll always get a the key/value pair formatted as: `key=value`. Procs/lambdas allow you to lazy evaluate your tag at time of logging which provides a powerful way to acquire the current
|
684
|
+
With the above, we have string, symbol, integer, hash, and proc tags. With hashes, you'll always get a the key/value pair formatted as: `key=value`. Procs/lambdas allow you to lazy evaluate your tag at time of logging which provides a powerful way to acquire the current process ID, thread ID, and so forth.
|
576
685
|
|
577
686
|
In addition to global tags, you can use local tags per log message. Example:
|
578
687
|
|
@@ -581,7 +690,7 @@ In addition to global tags, you can use local tags per log message. Example:
|
|
581
690
|
logger = Cogger.new
|
582
691
|
logger.info "Demo", tags: ["ONE", :two, 3, {four: "FOUR"}, proc { "FIVE" }]
|
583
692
|
|
584
|
-
🟢 [ONE] [two] [3] [FIVE] [four=FOUR] Demo
|
693
|
+
# 🟢 [ONE] [two] [3] [FIVE] [four=FOUR] Demo
|
585
694
|
----
|
586
695
|
|
587
696
|
You can also combine global and local tags:
|
@@ -604,43 +713,38 @@ As you can see, tags are highly versatile. That said, the following guidelines a
|
|
604
713
|
|
605
714
|
=== Filters
|
606
715
|
|
607
|
-
Filters allow you to mask sensitive information you don't want showing up in your logs.
|
716
|
+
Filters allow you to mask sensitive information you don't want showing up in your logs. The default is an empty set:
|
608
717
|
|
609
718
|
[source,ruby]
|
610
719
|
----
|
611
|
-
Cogger.filters
|
612
|
-
|
613
|
-
# [
|
614
|
-
# :_csrf,
|
615
|
-
# :password,
|
616
|
-
# :password_confirmation
|
617
|
-
# ]
|
720
|
+
Cogger.filters # #<Set: {}>
|
618
721
|
----
|
619
722
|
|
620
|
-
To add
|
723
|
+
To add filters, use:
|
621
724
|
|
622
725
|
[source,ruby]
|
623
726
|
----
|
624
727
|
Cogger.add_filter(:login)
|
625
728
|
.add_filter "email"
|
626
729
|
|
627
|
-
#
|
628
|
-
# :_csrf,
|
629
|
-
# :password,
|
630
|
-
# :password_confirmation,
|
631
|
-
# :login,
|
632
|
-
# :email
|
633
|
-
# ]
|
730
|
+
Cogger.filters # #<Set: {:login, :email}>
|
634
731
|
----
|
635
732
|
|
636
733
|
Symbols and strings can be used interchangeably but are stored as symbols since symbols are used when filtering log entries. Once your filters are in place, you can immediately see their effects:
|
637
734
|
|
638
735
|
[source,ruby]
|
639
736
|
----
|
737
|
+
Cogger.add_filter :password
|
640
738
|
logger = Cogger.new formatter: :json
|
641
739
|
logger.info login: "jayne", password: "secret"
|
642
740
|
|
643
|
-
# {
|
741
|
+
# {
|
742
|
+
# "id":"console",
|
743
|
+
# "severity":"INFO",
|
744
|
+
# "at":"2023-10-18 19:21:40 -0600",
|
745
|
+
# "login":"jayne",
|
746
|
+
# "password":"[FILTERED]"
|
747
|
+
# }
|
644
748
|
----
|
645
749
|
|
646
750
|
=== Streams
|
@@ -670,13 +774,13 @@ There is a lot you can do with streams. For example, if you wanted to experiment
|
|
670
774
|
|
671
775
|
[source,ruby]
|
672
776
|
----
|
673
|
-
|
777
|
+
logger = Cogger.new
|
674
778
|
.add_stream(formatter: :color)
|
675
779
|
.add_stream(formatter: :detail)
|
676
780
|
.add_stream(formatter: :json)
|
677
781
|
.add_stream(formatter: :simple)
|
678
782
|
|
679
|
-
|
783
|
+
logger.info "Demo"
|
680
784
|
|
681
785
|
# 🟢 Demo
|
682
786
|
# Demo
|
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.
|
5
|
+
spec.version = "0.13.0"
|
6
6
|
spec.authors = ["Brooke Kuhlmann"]
|
7
7
|
spec.email = ["brooke@alchemists.io"]
|
8
8
|
spec.homepage = "https://alchemists.io/projects/cogger"
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.cert_chain = [Gem.default_cert_path]
|
24
24
|
|
25
25
|
spec.required_ruby_version = "~> 3.2"
|
26
|
+
spec.add_dependency "core", "~> 0.1"
|
26
27
|
spec.add_dependency "refinements", "~> 11.0"
|
27
28
|
spec.add_dependency "tone", "~> 0.3"
|
28
29
|
spec.add_dependency "zeitwerk", "~> 2.6"
|
data/lib/cogger/configuration.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "core"
|
3
4
|
require "logger"
|
4
5
|
|
5
6
|
module Cogger
|
@@ -21,7 +22,7 @@ module Cogger
|
|
21
22
|
io: $stdout,
|
22
23
|
level: Logger.const_get(ENV.fetch("LOG_LEVEL", "INFO")),
|
23
24
|
formatter: Formatters::Emoji.new,
|
24
|
-
tags:
|
25
|
+
tags: Core::EMPTY_ARRAY,
|
25
26
|
mode: false,
|
26
27
|
age: 0,
|
27
28
|
size: 1_048_576,
|
data/lib/cogger/entry.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "core"
|
4
|
+
|
3
5
|
module Cogger
|
4
6
|
# Defines a log entry which can be formatted for output.
|
5
7
|
Entry = Data.define :id, :severity, :at, :message, :tags, :payload do
|
@@ -27,7 +29,7 @@ module Cogger
|
|
27
29
|
at: Time.now,
|
28
30
|
message: nil,
|
29
31
|
tags: [],
|
30
|
-
payload:
|
32
|
+
payload: Core::EMPTY_HASH
|
31
33
|
super
|
32
34
|
end
|
33
35
|
|
@@ -38,7 +40,7 @@ module Cogger
|
|
38
40
|
|
39
41
|
return attributes if computed_tags.empty?
|
40
42
|
|
41
|
-
{id:, severity:, at:, message:,
|
43
|
+
{id:, severity:, at:, message:, **computed_tags.to_h, **payload}
|
42
44
|
end
|
43
45
|
|
44
46
|
def tagged tagger: Tag
|
@@ -1,22 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "core"
|
3
4
|
require "json"
|
4
5
|
|
5
6
|
module Cogger
|
6
7
|
module Formatters
|
7
8
|
# Formats as JSON output.
|
8
9
|
class JSON
|
9
|
-
TEMPLATE =
|
10
|
+
TEMPLATE = nil
|
10
11
|
|
11
12
|
def initialize template = TEMPLATE,
|
12
13
|
parser: Parsers::Individual.new,
|
13
14
|
sanitizer: Kit::Sanitizer
|
14
|
-
@positions = parser.call(template).last.keys
|
15
|
+
@positions = template ? parser.call(template).last.keys : Core::EMPTY_ARRAY
|
15
16
|
@sanitizer = sanitizer
|
16
17
|
end
|
17
18
|
|
18
19
|
def call(*input)
|
19
20
|
attributes = sanitizer.call(*input).tagged_attributes.tap(&:compact!)
|
21
|
+
|
22
|
+
return "#{attributes.to_json}\n" if positions.empty?
|
23
|
+
|
20
24
|
"#{attributes.slice(*positions).merge!(attributes.except(*positions)).to_json}\n"
|
21
25
|
end
|
22
26
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "core"
|
4
|
+
|
3
5
|
module Cogger
|
4
6
|
module Formatters
|
5
7
|
module Parsers
|
@@ -32,7 +34,7 @@ module Cogger
|
|
32
34
|
def call template
|
33
35
|
return template unless template.match? pattern
|
34
36
|
|
35
|
-
[template.gsub(pattern,
|
37
|
+
[template.gsub(pattern, Core::EMPTY_STRING), template.match(pattern)[key]]
|
36
38
|
end
|
37
39
|
|
38
40
|
private
|
data/lib/cogger/hub.rb
CHANGED
@@ -33,6 +33,8 @@ module Cogger
|
|
33
33
|
level=
|
34
34
|
] => :primary
|
35
35
|
|
36
|
+
delegate %i[id io tags mode age size suffix] => :configuration
|
37
|
+
|
36
38
|
def initialize(registry: Cogger, model: Configuration, **attributes)
|
37
39
|
@registry = registry
|
38
40
|
@configuration = model[**find_formatter(attributes)]
|
@@ -59,6 +61,10 @@ module Cogger
|
|
59
61
|
|
60
62
|
def any(message = nil, **payload, &) = log(__method__, message, **payload, &)
|
61
63
|
|
64
|
+
def add(severity, message = nil, **payload, &)
|
65
|
+
log(Logger::SEV_LABEL.fetch(severity, "ANY").downcase, message, **payload, &)
|
66
|
+
end
|
67
|
+
|
62
68
|
alias unknown any
|
63
69
|
|
64
70
|
def reread = primary.reread
|
@@ -82,7 +88,7 @@ module Cogger
|
|
82
88
|
)
|
83
89
|
end
|
84
90
|
|
85
|
-
def log(severity, message, **payload, &)
|
91
|
+
def log(severity, message = nil, **payload, &)
|
86
92
|
dispatch(severity, message, **payload, &)
|
87
93
|
rescue StandardError => error
|
88
94
|
crash message, error
|
data/lib/cogger/registry.rb
CHANGED
@@ -18,9 +18,6 @@ module Cogger
|
|
18
18
|
.add_emoji(:error, "🛑")
|
19
19
|
.add_emoji(:fatal, "🔥")
|
20
20
|
.add_emoji(:any, "⚫️")
|
21
|
-
.add_filter(:_csrf)
|
22
|
-
.add_filter(:password)
|
23
|
-
.add_filter(:password_confirmation)
|
24
21
|
.add_formatter(:color, Cogger::Formatters::Color)
|
25
22
|
.add_formatter(
|
26
23
|
:detail,
|
data/lib/cogger/tag.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "core"
|
4
|
+
require "refinements/hashes"
|
5
|
+
|
3
6
|
module Cogger
|
4
7
|
# Models a tag which may consist of an array and/or hash.
|
5
8
|
Tag = Data.define :singles, :pairs do
|
9
|
+
using Refinements::Hashes
|
10
|
+
|
6
11
|
def self.for(*bag)
|
7
12
|
bag.each.with_object new do |item, tag|
|
8
13
|
value = item.is_a?(Proc) ? item.call : item
|
@@ -16,14 +21,9 @@ module Cogger
|
|
16
21
|
|
17
22
|
def empty? = singles.empty? && pairs.empty?
|
18
23
|
|
19
|
-
def to_a
|
20
|
-
return [] if empty?
|
21
|
-
|
22
|
-
pairs.map { |key, value| "#{key}=#{value}" }
|
23
|
-
.prepend(*singles.map(&:to_s))
|
24
|
-
end
|
24
|
+
def to_h = empty? ? Core::EMPTY_HASH : {tags: singles.to_a, **pairs}.tap(&:compress!)
|
25
25
|
|
26
|
-
def to_s = empty? ?
|
26
|
+
def to_s = empty? ? Core::EMPTY_STRING : "#{format_singles} #{format_pairs}".tap(&:strip!)
|
27
27
|
|
28
28
|
private
|
29
29
|
|
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.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -35,8 +35,22 @@ cert_chain:
|
|
35
35
|
3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
|
36
36
|
gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2023-10-
|
38
|
+
date: 2023-10-19 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: core
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.1'
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.1'
|
40
54
|
- !ruby/object:Gem::Dependency
|
41
55
|
name: refinements
|
42
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -135,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
149
|
- !ruby/object:Gem::Version
|
136
150
|
version: '0'
|
137
151
|
requirements: []
|
138
|
-
rubygems_version: 3.4.
|
152
|
+
rubygems_version: 3.4.21
|
139
153
|
signing_key:
|
140
154
|
specification_version: 4
|
141
155
|
summary: A customizable and feature rich logger.
|
metadata.gz.sig
CHANGED
Binary file
|