getaround_utils 0.1.7 → 0.1.8

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
- SHA1:
3
- metadata.gz: b8b08a78e3737d628b9e809bb89c670252fc37ba
4
- data.tar.gz: 34aa0786e2093c01af30981539cf971c275e5f14
2
+ SHA256:
3
+ metadata.gz: 391634ba2c0e6d1c3fe81bbdaf24519a84dfaa61fa093b8cb5ef10b3b47445a1
4
+ data.tar.gz: 0733525cd736128b202d0c6e8e87bb724685a09a8349ddb6fcdaccd8d10e6bee
5
5
  SHA512:
6
- metadata.gz: 96e165d62becbae525d2c717b2fa503149745ec3d8ca74ca70677d373dded88acdcdd67aadb05aa1474c89dff88ed2e4e34b2ceef2a001d2b13f391c0deecc50
7
- data.tar.gz: 92a70522d2ba91b312bf5c985d3394f18a54d2dd7e2217ab1fbf973b5f666cafc26c309be3ee11287cf3f604a22bc903b666404b6068823307b2983ebf328940
6
+ metadata.gz: 9e1b37388a0f05c21337941a8badddbc4e0411c61bceb9e326d9e0c99d16459c7df9868d4e2b6a2dda566f08ff19ae56f939f33198cbd929165f7fab3086d2d1
7
+ data.tar.gz: '095c102942a20a9fc4f9ec0ea445a560ced7b34bf9dab794e151c273b0b6845a84d888a7cb12a6542e37bfd5d26b675214769bdc82fe42adb9306c507cdbf1f2'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- getaround_utils (0.1.6)
4
+ getaround_utils (0.1.8)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -28,11 +28,11 @@ class MyClass
28
28
  end
29
29
 
30
30
  def action
31
- loggable(:info, dynamic: 'value')
31
+ loggable(:info, 'hello', dynamic: 'value')
32
32
  end
33
33
  end
34
34
 
35
- MyClass.new.action # :info { origin: 'MyClass', static: 'value', dynamic: 'value' }
35
+ MyClass.new.action # :info message="hello" origin="MyClass" static="value" dynamic="value"
36
36
 
37
37
  ```
38
38
 
@@ -15,7 +15,7 @@ class GetaroundUtils::LogFormatters::DeepKeyValue < GetaroundUtils::Utils::DeepK
15
15
  if message.is_a?(Hash)
16
16
  "#{serialize(payload.merge(message).compact)}\n"
17
17
  else
18
- "#{serialize(payload.merge(message: message.to_s).compact)}\n"
18
+ "#{serialize(payload.compact)} #{message}\n"
19
19
  end
20
20
  end
21
21
 
@@ -36,10 +36,16 @@ class GetaroundUtils::LogFormatters::DeepKeyValue < GetaroundUtils::Utils::DeepK
36
36
  end
37
37
 
38
38
  module Sidekiq
39
- def call(severity, datetime, appname, message)
40
- payload = { tid: Thread.current['sidekiq_tid'] }
41
- payload.merge!(Thread.current[:sidekiq_context] || {})
42
- "#{super.chomp} #{serialize(sidekiq: payload.compact)}\n"
39
+ def call(severity, _datetime, appname, message)
40
+ payload = {}
41
+ payload[:sidekiq] = Thread.current[:sidekiq_context] || {}
42
+ payload[:sidekiq][:tid] = Thread.current['sidekiq_tid']
43
+ message = if message.is_a?(Hash)
44
+ message.merge(payload.compact)
45
+ else
46
+ "#{serialize(payload.compact)} #{message}"
47
+ end
48
+ super
43
49
  end
44
50
  end
45
51
 
@@ -24,10 +24,15 @@ module GetaroundUtils::Mixins::Loggable
24
24
  end
25
25
  end
26
26
 
27
- def loggable(severity, payload)
28
- extra_infos = {}
29
- base_append_infos_to_loggable(extra_infos)
30
- payload = payload.merge(extra_infos).compact
31
- base_loggable_logger.send(severity.to_sym, payload)
27
+ def loggable_formatter
28
+ @loggable_formatter ||= GetaroundUtils::Utils::DeepKeyValueSerializer.new
29
+ end
30
+
31
+ def loggable(severity, message, payload = {})
32
+ payload = { message: message }.merge(payload)
33
+ base_append_infos_to_loggable(payload)
34
+
35
+ message = loggable_formatter.serialize(payload.compact)
36
+ base_loggable_logger.send(severity.to_sym, message)
32
37
  end
33
38
  end
@@ -1,4 +1,3 @@
1
1
  module GetaroundUtils::Patches
2
- autoload :FixTaggedLoggingStringCoercion, 'getaround_utils/patches/fix_tagged_logging_string_coercion'
3
2
  autoload :KeyValueLogTags, 'getaround_utils/patches/key_value_log_tags'
4
3
  end
@@ -1,3 +1,3 @@
1
1
  module GetaroundUtils
2
- VERSION = '0.1.7'.freeze
2
+ VERSION = '0.1.8'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: getaround_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Drivy
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-11-12 00:00:00.000000000 Z
12
+ date: 2019-11-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -29,20 +29,20 @@ dependencies:
29
29
  name: getaround-rubocop
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: 0.1.0
35
- - - ">="
35
+ - - "~>"
36
36
  - !ruby/object:Gem::Version
37
37
  version: 0.1.0
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  requirements:
42
- - - "~>"
42
+ - - ">="
43
43
  - !ruby/object:Gem::Version
44
44
  version: 0.1.0
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.1.0
48
48
  - !ruby/object:Gem::Dependency
@@ -105,22 +105,22 @@ dependencies:
105
105
  name: rspec
106
106
  requirement: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '3.9'
111
108
  - - ">="
112
109
  - !ruby/object:Gem::Version
113
110
  version: 3.9.0
111
+ - - "~>"
112
+ - !ruby/object:Gem::Version
113
+ version: '3.9'
114
114
  type: :development
115
115
  prerelease: false
116
116
  version_requirements: !ruby/object:Gem::Requirement
117
117
  requirements:
118
- - - "~>"
119
- - !ruby/object:Gem::Version
120
- version: '3.9'
121
118
  - - ">="
122
119
  - !ruby/object:Gem::Version
123
120
  version: 3.9.0
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '3.9'
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: rspec-rails
126
126
  requirement: !ruby/object:Gem::Requirement
@@ -139,42 +139,42 @@ dependencies:
139
139
  name: rubocop
140
140
  requirement: !ruby/object:Gem::Requirement
141
141
  requirements:
142
- - - "~>"
143
- - !ruby/object:Gem::Version
144
- version: '0.75'
145
142
  - - ">="
146
143
  - !ruby/object:Gem::Version
147
144
  version: 0.75.0
145
+ - - "~>"
146
+ - !ruby/object:Gem::Version
147
+ version: '0.75'
148
148
  type: :development
149
149
  prerelease: false
150
150
  version_requirements: !ruby/object:Gem::Requirement
151
151
  requirements:
152
- - - "~>"
153
- - !ruby/object:Gem::Version
154
- version: '0.75'
155
152
  - - ">="
156
153
  - !ruby/object:Gem::Version
157
154
  version: 0.75.0
155
+ - - "~>"
156
+ - !ruby/object:Gem::Version
157
+ version: '0.75'
158
158
  - !ruby/object:Gem::Dependency
159
159
  name: rubocop-rspec
160
160
  requirement: !ruby/object:Gem::Requirement
161
161
  requirements:
162
- - - "~>"
163
- - !ruby/object:Gem::Version
164
- version: '1.36'
165
162
  - - ">="
166
163
  - !ruby/object:Gem::Version
167
164
  version: 0.36.0
165
+ - - "~>"
166
+ - !ruby/object:Gem::Version
167
+ version: '1.36'
168
168
  type: :development
169
169
  prerelease: false
170
170
  version_requirements: !ruby/object:Gem::Requirement
171
171
  requirements:
172
- - - "~>"
173
- - !ruby/object:Gem::Version
174
- version: '1.36'
175
172
  - - ">="
176
173
  - !ruby/object:Gem::Version
177
174
  version: 0.36.0
175
+ - - "~>"
176
+ - !ruby/object:Gem::Version
177
+ version: '1.36'
178
178
  description: Shared base utility classes for Getaround Backend Applications.
179
179
  email:
180
180
  - oss@drivy.com
@@ -193,7 +193,6 @@ files:
193
193
  - lib/getaround_utils/mixins.rb
194
194
  - lib/getaround_utils/mixins/loggable.rb
195
195
  - lib/getaround_utils/patches.rb
196
- - lib/getaround_utils/patches/fix_tagged_logging_string_coercion.rb
197
196
  - lib/getaround_utils/patches/key_value_log_tags.rb
198
197
  - lib/getaround_utils/railties/lograge.rb
199
198
  - lib/getaround_utils/utils.rb
@@ -218,8 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
217
  - !ruby/object:Gem::Version
219
218
  version: '0'
220
219
  requirements: []
221
- rubyforge_project:
222
- rubygems_version: 2.5.2.3
220
+ rubygems_version: 3.0.3
223
221
  signing_key:
224
222
  specification_version: 4
225
223
  summary: Backend shared utility classes
@@ -1,32 +0,0 @@
1
- require 'rails/railtie'
2
- module GetaroundUtils; end
3
- module GetaroundUtils::Patches; end
4
-
5
- ##
6
- # Fixes the ActiveSupport::TaggedLogging::Formatter string coercion
7
- #
8
- # Ruby Logger and child classes don't necessarilly expect message to be string.
9
- # In theory, they should preserve the message value intact until it is passed to the formatter.
10
- #
11
- # ActiveSupport::TaggedLogging breaks this by injecting the tags via string concatenation,
12
- # which coerces messages of any type into String.
13
- # This patches works around this by instead appending the tags to the result of the
14
- # original formatter result, which is garanteed to be a string
15
-
16
- class GetaroundUtils::Patches::FixTaggedLoggingStringCoercion
17
- module TaggedLoggingFormatter
18
- def fixed_tags_text
19
- " #{tags_text.strip}" if tags_text
20
- end
21
-
22
- def call(severity, datetime, appname, message)
23
- original_method = method(__method__).super_method.super_method
24
- payload = original_method.call(severity, datetime, appname, message)
25
- "#{payload.chomp}#{fixed_tags_text}\n"
26
- end
27
- end
28
-
29
- def self.enable
30
- ActiveSupport::TaggedLogging::Formatter.prepend TaggedLoggingFormatter
31
- end
32
- end