semantic_logger 4.10.0 → 4.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ff7d4bcb345581f6ba19f834bb1bf2f921e97904f4b6236142b87af75a4526d
4
- data.tar.gz: b1069d5360296c61c9796f630b1ec065eb1a0a7dc549778c66c5e26c90d0eadb
3
+ metadata.gz: ef345374458ca40a1c31ab82b43fa040974c586fd089a3a5a2a5ab6fe0393c77
4
+ data.tar.gz: a7d13c0f42e7571b3ddcc47303f83a4b28a2b46929134be7d02e9c5af23d2963
5
5
  SHA512:
6
- metadata.gz: c5cfbac7dd8795b11cf79ed3fa9a4a086128d5ee030f0e9db40b75f30f58997c1674a4284b4b287939216bc8de83372e2b7fe00d73e7856c3cc6830310740f0d
7
- data.tar.gz: 2150a809562247d771103a5d387ae5852ff5b0649a4f4288a7dd07a94420bafcfb6b36f3e21077fcc053c2d8bcaffe80a110ab65b52178fb612b7368fd79d87d
6
+ metadata.gz: 0c4913a0f50f89e9b92b03b89c01b8a02f71f29efd6c06ae0c3f59b49c290b5878569cc6e5a946a7cc29943974d822a29481e6bd83d33c0de66f87f4b524e05c
7
+ data.tar.gz: ffe8ca5c2ce97b4bfe67bd79b4ae562c509c577cc70daca9128fe2c28cb7e92f1f6e567e4fb5199f89927653b6a1a3d32d53d6287e5f96ec935207534027746f
@@ -23,7 +23,7 @@ module SemanticLogger
23
23
  module Appender
24
24
  class Kafka < SemanticLogger::Subscriber
25
25
  attr_accessor :seed_brokers, :client_id, :connect_timeout, :socket_timeout,
26
- :ssl_ca_cert, :ssl_client_cert, :ssl_client_cert_key,
26
+ :ssl_ca_cert, :ssl_client_cert, :ssl_client_cert_key, :ssl_ca_certs_from_system,
27
27
  :delivery_threshold, :delivery_interval,
28
28
  :topic, :partition, :partition_key, :key
29
29
 
@@ -79,6 +79,9 @@ module SemanticLogger
79
79
  # Must be used in combination with ssl_client_cert.
80
80
  # Default: nil
81
81
  #
82
+ # ssl_ca_certs_from_system: [boolean]
83
+ # Delegate SSL CA cert to the system certs
84
+ #
82
85
  # delivery_threshold: [Integer]
83
86
  # Number of messages between triggering a delivery of messages to Apache Kafka.
84
87
  # Default: 100
@@ -116,24 +119,25 @@ module SemanticLogger
116
119
  # Send metrics only events to kafka.
117
120
  # Default: true
118
121
  def initialize(seed_brokers:, client_id: "semantic-logger", connect_timeout: nil, socket_timeout: nil,
119
- ssl_ca_cert: nil, ssl_client_cert: nil, ssl_client_cert_key: nil,
122
+ ssl_ca_cert: nil, ssl_client_cert: nil, ssl_client_cert_key: nil, ssl_ca_certs_from_system: false,
120
123
  topic: "log_messages", partition: nil, partition_key: nil, key: nil,
121
124
  delivery_threshold: 100, delivery_interval: 10,
122
125
  metrics: true, **args, &block)
123
126
 
124
- @seed_brokers = seed_brokers
125
- @client_id = client_id
126
- @connect_timeout = connect_timeout
127
- @socket_timeout = socket_timeout
128
- @ssl_ca_cert = ssl_ca_cert
129
- @ssl_client_cert = ssl_client_cert
130
- @ssl_client_cert_key = ssl_client_cert_key
131
- @topic = topic
132
- @partition = partition
133
- @partition_key = partition_key
134
- @key = key
135
- @delivery_threshold = delivery_threshold
136
- @delivery_interval = delivery_interval
127
+ @seed_brokers = seed_brokers
128
+ @client_id = client_id
129
+ @connect_timeout = connect_timeout
130
+ @socket_timeout = socket_timeout
131
+ @ssl_ca_cert = ssl_ca_cert
132
+ @ssl_client_cert = ssl_client_cert
133
+ @ssl_client_cert_key = ssl_client_cert_key
134
+ @ssl_ca_certs_from_system = ssl_ca_certs_from_system
135
+ @topic = topic
136
+ @partition = partition
137
+ @partition_key = partition_key
138
+ @key = key
139
+ @delivery_threshold = delivery_threshold
140
+ @delivery_interval = delivery_interval
137
141
 
138
142
  super(metrics: metrics, **args, &block)
139
143
  reopen
@@ -141,14 +145,15 @@ module SemanticLogger
141
145
 
142
146
  def reopen
143
147
  @kafka = ::Kafka.new(
144
- seed_brokers: seed_brokers,
145
- client_id: client_id,
146
- connect_timeout: connect_timeout,
147
- socket_timeout: socket_timeout,
148
- ssl_ca_cert: ssl_ca_cert,
149
- ssl_client_cert: ssl_client_cert,
150
- ssl_client_cert_key: ssl_client_cert_key,
151
- logger: logger
148
+ seed_brokers: seed_brokers,
149
+ client_id: client_id,
150
+ connect_timeout: connect_timeout,
151
+ socket_timeout: socket_timeout,
152
+ ssl_ca_cert: ssl_ca_cert,
153
+ ssl_client_cert: ssl_client_cert,
154
+ ssl_client_cert_key: ssl_client_cert_key,
155
+ ssl_ca_certs_from_system: ssl_ca_certs_from_system,
156
+ logger: logger
152
157
  )
153
158
 
154
159
  @producer = @kafka.async_producer(
@@ -186,7 +186,8 @@ module SemanticLogger
186
186
  # to:
187
187
  # `logger.tagged('first', 'more', 'other')`
188
188
  # - For better performance with clean tags, see `SemanticLogger.tagged`.
189
- def tagged(*tags, &block)
189
+ def tagged(*tags)
190
+ block = -> { yield(self) }
190
191
  # Allow named tags to be passed into the logger
191
192
  # Rails::Rack::Logger passes logs as an array with a single argument
192
193
  if tags.size == 1 && !tags.first.is_a?(Array)
@@ -327,14 +328,14 @@ module SemanticLogger
327
328
 
328
329
  log = Log.new(name, level, index)
329
330
  should_log =
330
- if payload.nil? && exception.nil? && message.is_a?(Hash)
331
- # Everything as keyword arguments.
331
+ if exception.nil? && payload.nil? && message.is_a?(Hash)
332
+ # All arguments as a hash in the message.
332
333
  log.assign(**log.extract_arguments(message))
333
334
  elsif exception.nil? && message && payload && payload.is_a?(Hash)
334
- # Message with keyword arguments as the rest.
335
- log.assign(message: message, **log.extract_arguments(payload))
335
+ # Message supplied along with a hash with the remaining arguments.
336
+ log.assign(**log.extract_arguments(payload, message))
336
337
  else
337
- # No keyword arguments.
338
+ # All fields supplied directly.
338
339
  log.assign(message: message, payload: payload, exception: exception)
339
340
  end
340
341
 
@@ -140,14 +140,25 @@ module SemanticLogger
140
140
  end
141
141
 
142
142
  # Extract the arguments from a Hash Payload
143
- def extract_arguments(payload)
143
+ def extract_arguments(payload, message = nil)
144
144
  raise(ArgumentError, "payload must be a Hash") unless payload.is_a?(Hash)
145
145
 
146
+ message = nil if message == ""
146
147
  return payload if payload.key?(:payload)
147
148
 
148
- args = {}
149
- payload.each_key { |key| args[key] = payload.delete(key) if NON_PAYLOAD_KEYS.include?(key) }
150
- args[:payload] = payload unless payload.empty?
149
+ new_payload = {}
150
+ args = {}
151
+ payload.each_pair do |key, value|
152
+ # Supplied message takes precedence
153
+ if (key == :message) && !message.nil?
154
+ new_payload[key] = value
155
+ next
156
+ end
157
+
158
+ NON_PAYLOAD_KEYS.include?(key) ? args[key] = value : new_payload[key] = value
159
+ end
160
+ args[:payload] = new_payload unless new_payload.empty?
161
+ args[:message] = message if message
151
162
  args
152
163
  end
153
164
 
@@ -1,3 +1,3 @@
1
1
  module SemanticLogger
2
- VERSION = "4.10.0".freeze
2
+ VERSION = "4.11.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semantic_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.10.0
4
+ version: 4.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reid Morrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-05 00:00:00.000000000 Z
11
+ date: 2022-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
113
  requirements: []
114
- rubygems_version: 3.3.3
114
+ rubygems_version: 3.3.7
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: Feature rich logging framework, and replacement for existing Ruby & Rails