getaround_utils 0.2.0 → 0.2.9

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: bdcc5b1460329ad345ef3d8a3be543c4e4d9b5b626d4c71551c698513df16a97
4
- data.tar.gz: 876b086f9f1ef2b411409ffcfd5f2d16676fed5fa87d40020f254efc3e2d9b7c
3
+ metadata.gz: c42ef677431ceda95a517423c02274ee8a3972f374be40743f519bb3ab3f6c11
4
+ data.tar.gz: f695fe8fd906c44ebf894c22990913077b66b5def97ff14c6ec8084c40fa982a
5
5
  SHA512:
6
- metadata.gz: 42967aa90f0c6384d87d9b1c1d7fde77526b3949a854107b438c9968524736df6e6b044dd8674d92c6d53e36e4c3024debbbc1ef799fcea62a034ad7a733e94d
7
- data.tar.gz: c23299cce88fd8bf7ecc9741ddda44e3a14d7e68b2f06fe359fcac88d635a91513c4dfe930437e65054ea30363b07d3aa52d84e7f10a09932d705ba250c120f1
6
+ metadata.gz: '029d3cdfbd61b334ad96898377cae44b13244409f92022138cc832168dff1bc7dd94415d1a5a02760f7498f8a7eac0c502413645900e5b3873f20e49033203cc'
7
+ data.tar.gz: 1313d197fc287364b9b3a28e90607873ac8e7d3450b173d5cea607a64a01160e971894136f40ca1e28d6fb75c8bc8db41b731fb4d8d3b11f9e978d668d25989a
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- getaround_utils (0.2.0)
4
+ getaround_utils (0.2.9)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -34,6 +34,6 @@ module GetaroundUtils::Mixins::Loggable
34
34
 
35
35
  def loggable_log(severity, message, payload = {})
36
36
  base_append_infos_to_loggable(payload)
37
- base_loggable_logger.send(severity.to_sym, message, payload)
37
+ base_loggable_logger.send(severity.to_sym, msg: message, **payload)
38
38
  end
39
39
  end
@@ -1,15 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'ougai'
2
4
  require 'getaround_utils/utils/deep_key_value'
3
5
 
4
6
  module GetaroundUtils; end
5
7
  module GetaroundUtils::Ougai; end
6
8
 
7
- class GetaroundUtils::Ougai::DeepKeyValuesFormatter < Ougai::Formatters::Base
9
+ class GetaroundUtils::Ougai::DeepKeyValueFormatter < Ougai::Formatters::Base
8
10
  def _call(severity, _time, progname, data)
9
- data.delete(:msg) if data[:msg] == 'No message'
10
- data = data.except(:msg).merge(message: data[:msg])
11
+ message = data.delete(:msg)
12
+ data[:message] = message if message != 'No message'
11
13
 
12
- payload = { severity: severity, progname: progname }.merge(data).compact!
14
+ payload = { severity: severity, progname: progname }.merge(data).compact
13
15
  GetaroundUtils::Utils::DeepKeyValue.serialize(payload) + "\n"
14
16
  end
15
17
  end
@@ -7,10 +7,11 @@ module GetaroundUtils::Ougai; end
7
7
 
8
8
  class GetaroundUtils::Ougai::JsonFormatter < Ougai::Formatters::Base
9
9
  def _call(severity, _time, progname, data)
10
- data.delete(:msg) if data[:msg] == 'No message'
11
- data = data.except(:msg).merge(message: data[:msg])
10
+ message = data.delete(:msg)
11
+ data = { caption: message }.merge(data) \
12
+ unless message == 'No message'
12
13
 
13
- payload = { severity: severity, progname: progname }.merge(data).compact!
14
+ payload = { severity: severity, progname: progname }.merge(data).compact
14
15
  JSON.dump(payload) + "\n"
15
16
  end
16
17
  end
@@ -19,9 +19,13 @@ end
19
19
  # https://github.com/tilfin/ougai/wiki/Use-as-Rails-logger#with-activesupporttaggedlogging
20
20
  module OugaiTaggedLoggingFormatter
21
21
  def call(severity, time, progname, data)
22
- data = { msg: data.to_s } unless data.is_a?(Hash)
23
- data[:tags] = current_tags if current_tags.any?
24
- _call(severity, time, progname, data)
22
+ if is_a?(Ougai::Formatters::Base)
23
+ data = { msg: data.to_s } unless data.is_a?(Hash)
24
+ data[:tags] = current_tags if current_tags.any?
25
+ _call(severity, time, progname, data)
26
+ else
27
+ super
28
+ end
25
29
  end
26
30
  end
27
31
 
@@ -40,12 +44,9 @@ class OugaiRequestStoreMiddleware
40
44
  end
41
45
 
42
46
  class GetaroundUtils::Railties::Ougai < Rails::Railtie
43
- log_level = ENV.fetch('LOG_LEVEL', :info).to_sym
44
-
45
47
  config.ougai_logger = OugaiRailsLogger.new(STDOUT)
46
48
  config.ougai_logger.after_initialize if Rails::VERSION::MAJOR < 6
47
- config.ougai_logger.level = log_level
48
- config.ougai_logger.formatter = GetaroundUtils::Ougai::DeepKeyValuesFormatter.new
49
+ config.ougai_logger.formatter = GetaroundUtils::Ougai::DeepKeyValueFormatter.new
49
50
  config.ougai_logger.before_log = lambda do |data|
50
51
  request_store = RequestStore.store[:ougai] || {}
51
52
  data.merge!(request_store) if request_store&.any?
@@ -55,15 +56,6 @@ class GetaroundUtils::Railties::Ougai < Rails::Railtie
55
56
  end
56
57
 
57
58
  initializer :getaround_utils_ougai, before: :initialize_logger do |app|
58
- LOG_LEVELS = {
59
- Logger::DEBUG => :debug,
60
- Logger::INFO => :info,
61
- Logger::WARN => :warn,
62
- Logger::ERROR => :error,
63
- Logger::FATAL => :fatal,
64
- }.freeze
65
-
66
- app.config.log_level = LOG_LEVELS[config.ougai_logger.level] || :info
67
59
  app.config.logger = config.ougai_logger
68
60
  end
69
61
 
@@ -89,7 +81,7 @@ class GetaroundUtils::Railties::Ougai < Rails::Railtie
89
81
  Sidekiq.logger = config.ougai_logger
90
82
 
91
83
  Sidekiq.configure_server do |config|
92
- config.error_handlers.pop
84
+ config.error_handlers.shift
93
85
  config.error_handlers << lambda do |ex, ctx|
94
86
  Sidekiq.logger.warn(ex, job: ctx[:job])
95
87
  end
@@ -1,3 +1,3 @@
1
1
  module GetaroundUtils
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.2.9'.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.2.0
4
+ version: 0.2.9
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: 2020-09-11 00:00:00.000000000 Z
12
+ date: 2020-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler