rails_semantic_logger 4.4.6 → 4.5.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: de0436e82a0d6ed583904e4da19a5dbc5611e7673b1b9904b0b4757f00e71057
4
- data.tar.gz: 42335c2218f2d434f352f695c9ce2cc9362c7b7cbe70664a3585d5910c91e6f7
3
+ metadata.gz: 073a9356b40dc5616e3e4b179ea108d7419dc9e4bba685c230e41acd93ca48d4
4
+ data.tar.gz: 106766c0a81ed7a2d7b25c7810aa1edac1eedf5638426373209b168d7ea57b43
5
5
  SHA512:
6
- metadata.gz: e0681cc160523f2cef6b6c5fdb169147150bf26470ce628210877e41691911fd81c0f800320dea191d61c6e7be0e3b2ad9d6bf259d0b711caad1c934ec914a72
7
- data.tar.gz: 3e276c344146b0b16b71b1bfa915b0e8d602c20c750322fca09179c95ac3d85a1138e7b8bbaa96fc62f30effaf09d36cde8e5e7eb8268edbcf3f0e7f1c597f3c
6
+ metadata.gz: fd450ba87b0d22e139fd7afa626ed4fb8566e3ebc70880c05fe2c73c1ff5067a8d3626a8bddd742160a3d25eced3f8e4431e1fac96432f0fe53e6ec740c78d46
7
+ data.tar.gz: 2bee7d442cab44140f00b9ca74d0b343d6e19933953487c5b21c094bea0c7f811f2bb6014090eda6a778eb1ebd8209f86a9b4c3afb471fd1fa9955ad3fc160e4
@@ -37,6 +37,9 @@ module RailsSemanticLogger
37
37
  payload[key] = payload[key].to_f.round(2) if key.to_s =~ /(.*)_runtime/
38
38
  end
39
39
 
40
+ # Rails 6+ includes allocation count
41
+ payload[:allocations] = event.allocations if event.respond_to?(:allocations)
42
+
40
43
  payload[:status_message] = ::Rack::Utils::HTTP_STATUS_CODES[payload[:status]] if payload[:status].present?
41
44
 
42
45
  # Causes excessive log output with Rails 5 RC1
@@ -23,6 +23,7 @@ module RailsSemanticLogger
23
23
  template: from_rails_root(event.payload[:identifier])
24
24
  }
25
25
  payload[:within] = from_rails_root(event.payload[:layout]) if event.payload[:layout]
26
+ payload[:allocations] = event.allocations if event.respond_to?(:allocations)
26
27
 
27
28
  logger.measure(
28
29
  self.class.rendered_log_level,
@@ -40,6 +41,7 @@ module RailsSemanticLogger
40
41
  }
41
42
  payload[:within] = from_rails_root(event.payload[:layout]) if event.payload[:layout]
42
43
  payload[:cache] = payload[:cache_hit] unless event.payload[:cache_hit].nil?
44
+ payload[:allocations] = event.allocations if event.respond_to?(:allocations)
43
45
 
44
46
  logger.measure(
45
47
  self.class.rendered_log_level,
@@ -59,6 +61,7 @@ module RailsSemanticLogger
59
61
  count: event.payload[:count]
60
62
  }
61
63
  payload[:cache_hits] = payload[:cache_hits] if payload[:cache_hits]
64
+ payload[:allocations] = event.allocations if event.respond_to?(:allocations)
62
65
 
63
66
  logger.measure(
64
67
  self.class.rendered_log_level,
@@ -78,7 +78,11 @@ module RailsSemanticLogger
78
78
  end
79
79
 
80
80
  def formatted_args
81
- JSON.pretty_generate(job.arguments.map { |arg| format(arg) })
81
+ if defined?(job.class.log_arguments?) && !job.class.log_arguments?
82
+ ""
83
+ else
84
+ JSON.pretty_generate(job.arguments.map { |arg| format(arg) })
85
+ end
82
86
  end
83
87
 
84
88
  def format(arg)
@@ -31,6 +31,7 @@ module RailsSemanticLogger
31
31
 
32
32
  log_payload = {sql: payload[:sql]}
33
33
  log_payload[:binds] = bind_values(payload) unless (payload[:binds] || []).empty?
34
+ log_payload[:allocations] = event.allocations if event.respond_to?(:allocations)
34
35
 
35
36
  log = {
36
37
  message: name,
@@ -52,7 +53,7 @@ module RailsSemanticLogger
52
53
 
53
54
  # When multiple values are received for a single bound field, it is converted into an array
54
55
  def add_bind_value(binds, key, value)
55
- key = key.downcase.to_sym
56
+ key = key.downcase.to_sym unless key.nil?
56
57
  value = (Array(binds[key]) << value) if binds.key?(key)
57
58
  binds[key] = value
58
59
  end
@@ -115,6 +116,16 @@ module RailsSemanticLogger
115
116
  binds
116
117
  end
117
118
 
119
+ def bind_values_v6_1(payload)
120
+ binds = {}
121
+ casted_params = type_casted_binds(payload[:type_casted_binds])
122
+ payload[:binds].each_with_index do |attr, i|
123
+ attr_name, value = render_bind(attr, casted_params[i])
124
+ add_bind_value(binds, attr_name, value)
125
+ end
126
+ binds
127
+ end
128
+
118
129
  def render_bind_v4_2(column, value)
119
130
  if column
120
131
  if column.binary?
@@ -154,6 +165,21 @@ module RailsSemanticLogger
154
165
  [attr&.name, value]
155
166
  end
156
167
 
168
+ def render_bind_v6_1(attr, value)
169
+ case attr
170
+ when ActiveModel::Attribute
171
+ if attr.type.binary? && attr.value
172
+ value = "<#{attr.value_for_database.to_s.bytesize} bytes of binary data>"
173
+ end
174
+ when Array
175
+ attr = attr.first
176
+ else
177
+ attr = nil
178
+ end
179
+
180
+ [attr&.name, value]
181
+ end
182
+
157
183
  def type_casted_binds_v5_0_3(binds, casted_binds)
158
184
  casted_binds || ::ActiveRecord::Base.connection.type_casted_binds(binds)
159
185
  end
@@ -171,6 +197,10 @@ module RailsSemanticLogger
171
197
  alias bind_values bind_values_v5_0_3
172
198
  alias render_bind render_bind_v5_0_3
173
199
  alias type_casted_binds type_casted_binds_v5_0_3
200
+ elsif Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR > 0 # ~> 6.1.0
201
+ alias bind_values bind_values_v6_1
202
+ alias render_bind render_bind_v6_1
203
+ alias type_casted_binds type_casted_binds_v5_1_5
174
204
  elsif Rails::VERSION::MAJOR >= 5 # ~> 5.1.5 && ~> 5.0.7 && 6.x.x
175
205
  alias bind_values bind_values_v5_1_5
176
206
  alias render_bind render_bind_v5_0_3
@@ -1,3 +1,3 @@
1
1
  module RailsSemanticLogger
2
- VERSION = "4.4.6".freeze
2
+ VERSION = "4.5.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_semantic_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.6
4
+ version: 4.5.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: 2020-12-04 00:00:00.000000000 Z
11
+ date: 2021-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  - !ruby/object:Gem::Version
99
99
  version: '0'
100
100
  requirements: []
101
- rubygems_version: 3.0.8
101
+ rubygems_version: 3.2.3
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: Feature rich logging framework that replaces the Rails logger.