cogger 0.24.1 → 0.25.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,6 +26,7 @@ module Cogger
26
26
  )
27
27
  .add_formatter(:emoji, Cogger::Formatters::Emoji)
28
28
  .add_formatter(:json, Cogger::Formatters::JSON)
29
+ .add_formatter(:property, Cogger::Formatters::Property)
29
30
  .add_formatter(:simple, Cogger::Formatters::Simple)
30
31
  .add_formatter :rack,
31
32
  Cogger::Formatters::Simple,
@@ -59,8 +60,10 @@ module Cogger
59
60
  def filters = @filters ||= Set.new
60
61
 
61
62
  def add_formatter key, formatter, template = nil
62
- formatters[key.to_sym] = [formatter, template]
63
+ formatters[key.to_sym] = [formatter, template || formatter::TEMPLATE]
63
64
  self
65
+ rescue NameError
66
+ raise NameError, "#{formatter}::TEMPLATE must be defined with a default template string."
64
67
  end
65
68
 
66
69
  def get_formatter key
@@ -69,6 +72,12 @@ module Cogger
69
72
 
70
73
  def formatters = @formatters ||= {}
71
74
 
75
+ def templates
76
+ formatters.each.with_object({}) do |(key, (_formatter, template)), collection|
77
+ collection[key] = template
78
+ end
79
+ end
80
+
72
81
  def color = @color ||= Tone.new
73
82
 
74
83
  def defaults = {emojis:, aliases:, formatters:, filters:, color:}
data/lib/cogger.rb CHANGED
@@ -13,6 +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
17
  LEVELS = %w[debug info warn error fatal unknown].freeze
17
18
 
18
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: 0.24.1
4
+ version: 0.25.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-08-25 00:00:00.000000000 Z
38
+ date: 2024-08-28 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: core
@@ -108,20 +108,25 @@ files:
108
108
  - lib/cogger.rb
109
109
  - lib/cogger/configuration.rb
110
110
  - lib/cogger/entry.rb
111
+ - lib/cogger/formatters/abstract.rb
111
112
  - lib/cogger/formatters/color.rb
112
113
  - lib/cogger/formatters/crash.rb
113
114
  - lib/cogger/formatters/emoji.rb
114
115
  - lib/cogger/formatters/json.rb
115
- - lib/cogger/formatters/kit/colorizer.rb
116
- - lib/cogger/formatters/kit/sanitizer.rb
117
116
  - lib/cogger/formatters/parsers/abstract.rb
118
117
  - lib/cogger/formatters/parsers/combined.rb
119
118
  - lib/cogger/formatters/parsers/element.rb
120
119
  - lib/cogger/formatters/parsers/emoji.rb
120
+ - lib/cogger/formatters/parsers/key.rb
121
121
  - lib/cogger/formatters/parsers/key_extractor.rb
122
- - lib/cogger/formatters/parsers/specific.rb
123
- - lib/cogger/formatters/processors/color.rb
122
+ - lib/cogger/formatters/property.rb
123
+ - lib/cogger/formatters/sanitizers/date_time.rb
124
+ - lib/cogger/formatters/sanitizers/escape.rb
125
+ - lib/cogger/formatters/sanitizers/filter.rb
124
126
  - lib/cogger/formatters/simple.rb
127
+ - lib/cogger/formatters/transformers/color.rb
128
+ - lib/cogger/formatters/transformers/emoji.rb
129
+ - lib/cogger/formatters/transformers/key.rb
125
130
  - lib/cogger/hub.rb
126
131
  - lib/cogger/level.rb
127
132
  - lib/cogger/program.rb
@@ -158,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
163
  - !ruby/object:Gem::Version
159
164
  version: '0'
160
165
  requirements: []
161
- rubygems_version: 3.5.17
166
+ rubygems_version: 3.5.18
162
167
  signing_key:
163
168
  specification_version: 4
164
169
  summary: A customizable and feature rich logger.
metadata.gz.sig CHANGED
Binary file
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cogger
4
- module Formatters
5
- module Kit
6
- # Transform color based on dynamic (level) or standard color preference.
7
- Colorizer = lambda do |value, attributes|
8
- value == "dynamic" ? attributes[:level].downcase : value
9
- end
10
- end
11
- end
12
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cogger
4
- module Formatters
5
- module Kit
6
- # Ensures log entry is filtered of sensitive data.
7
- Sanitizer = lambda do |*input, filters: Cogger.filters|
8
- *, entry = input
9
-
10
- return Entry.for entry unless entry.is_a? Entry
11
-
12
- payload = entry.payload
13
- filters.each { |key| payload[key] = "[FILTERED]" if payload.key? key }
14
- entry
15
- end
16
- end
17
- end
18
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cogger
4
- module Formatters
5
- module Processors
6
- # Processes template with entry input using all template parsers.
7
- class Color
8
- def initialize parser: Parsers::Combined.new, sanitizer: Kit::Sanitizer
9
- @parser = parser
10
- @sanitizer = sanitizer
11
- end
12
-
13
- def call(template, *input)
14
- attributes = sanitizer.call(*input).tagged
15
- [parser.call(template, **attributes), attributes]
16
- end
17
-
18
- private
19
-
20
- attr_reader :parser, :sanitizer
21
- end
22
- end
23
- end
24
- end