rails_semantic_logger 4.2.0 → 4.2.1

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: bcc3cb8ba5dd32241b154e8d483caaf8571838dbfb842377d369f7c93e3bacd7
4
- data.tar.gz: 251daa71983a8c8098ba05ce759233a897bd1b4f0e018d03b4f01fcdcf81217c
3
+ metadata.gz: d56fd59e95eb5982a96ce3dd581a3249503c67e83751948648a50c575a357d24
4
+ data.tar.gz: bbe41e7f698388fd7b14ea3096f62d0316ef51e2ee4fd961f0a5046fe46ad97c
5
5
  SHA512:
6
- metadata.gz: dae75c826b49e9d2c2233a4c354d54938fb8f17ef63eb5ed27672f886135f5b20bdc177f2a402d5542524f0dbedfc7a9567b8fb04779550c63ecd381462f303f
7
- data.tar.gz: b156645f8b0e0357776d9e8ea27037c16e42e54543dac192a46c7c6aeb3cb2bbfd1448e82d1dbfdf30a49f094c74e4a9215a0618906772113593ab9b9dd4b549
6
+ metadata.gz: fa8f0f7cd9da16e76a3c0803f249710185e1adda00475dc6b4f88605c3893064114f4d7d763a8638ea3dd83e054e42233f2736041b98a259f4f3a12d6df825cc
7
+ data.tar.gz: 3a025e94a795aabcf96e612eb02ecec265656f5f8939a81908abb48464703693bdd862de6d5a5dc9cd0163b4bdc473d14c534ad2d6ceb2e09f3a4c9cfd210247
@@ -215,6 +215,20 @@ module RailsSemanticLogger
215
215
  # Replace the Sidetiq logger
216
216
  Sidetiq.logger = SemanticLogger[Sidetiq] if defined?(Sidetiq)
217
217
 
218
+ # Replace the DelayedJob logger
219
+ Delayed::Worker.logger = SemanticLogger[Delayed::Worker] if defined?(Delayed::Worker)
220
+
221
+ # Replace the Bugsnag logger
222
+ Bugsnag.configure { |config| config.logger = SemanticLogger[Bugsnag] } if defined?(Bugsnag)
223
+
224
+ # Backward compatibility
225
+ if config.rails_semantic_logger.named_tags
226
+ config.log_tags = config.rails_semantic_logger.named_tags
227
+ end
228
+ end
229
+
230
+ # After any initializers run, but after the gems have been loaded
231
+ config.after_initialize do
218
232
  # Replace the Bugsnag logger
219
233
  Bugsnag.configure { |config| config.logger = SemanticLogger[Bugsnag] } if defined?(Bugsnag)
220
234
 
@@ -243,17 +257,6 @@ module RailsSemanticLogger
243
257
  if config.rails_semantic_logger.processing
244
258
  require('rails_semantic_logger/extensions/action_controller/log_subscriber_processing') if defined?(ActionView::LogSubscriber)
245
259
  end
246
-
247
- # Backward compatibility
248
- if config.rails_semantic_logger.named_tags
249
- config.log_tags = config.rails_semantic_logger.named_tags
250
- end
251
- end
252
-
253
- # After any initializers run, but after the gems have been loaded
254
- config.after_initialize do
255
- # Replace the Bugsnag logger
256
- Bugsnag.configure { |config| config.logger = SemanticLogger[Bugsnag] } if defined?(Bugsnag)
257
260
  end
258
261
 
259
262
  end
@@ -10,7 +10,11 @@ module ActionController
10
10
 
11
11
  def process_action(event)
12
12
  controller_logger(event).info do
13
- payload = event.payload.dup
13
+ payload = event.payload.dup
14
+
15
+ # Unused, but needed for Devise 401 status code patch to still work.
16
+ ActionController::Base.log_process_action(payload)
17
+
14
18
  # According to PR https://github.com/rocketjob/rails_semantic_logger/pull/37/files
15
19
  # payload[:params] is not always a Hash.
16
20
  payload[:params] = payload[:params].to_unsafe_h unless payload[:params].is_a?(Hash)
@@ -46,19 +50,19 @@ module ActionController
46
50
  end
47
51
 
48
52
  def halted_callback(event)
49
- controller_logger(event).info {"Filter chain halted as #{event.payload[:filter].inspect} rendered or redirected"}
53
+ controller_logger(event).info { "Filter chain halted as #{event.payload[:filter].inspect} rendered or redirected" }
50
54
  end
51
55
 
52
56
  def send_file(event)
53
- controller_logger(event).info('Sent file') {{path: event.payload[:path], duration: event.duration}}
57
+ controller_logger(event).info('Sent file') { {path: event.payload[:path], duration: event.duration} }
54
58
  end
55
59
 
56
60
  def redirect_to(event)
57
- controller_logger(event).info('Redirected to') {{location: event.payload[:location]}}
61
+ controller_logger(event).info('Redirected to') { {location: event.payload[:location]} }
58
62
  end
59
63
 
60
64
  def send_data(event)
61
- controller_logger(event).info('Sent data') {{file_name: event.payload[:filename], duration: event.duration}}
65
+ controller_logger(event).info('Sent data') { {file_name: event.payload[:filename], duration: event.duration} }
62
66
  end
63
67
 
64
68
  def unpermitted_parameters(event)
@@ -15,7 +15,7 @@ module ActionController
15
15
  def controller_logger(event)
16
16
  if controller = event.payload[:controller]
17
17
  begin
18
- controller.constantize.logger
18
+ controller.constantize.logger || ActionController::Base.logger
19
19
  rescue NameError
20
20
  ActionController::Base.logger
21
21
  end
@@ -23,39 +23,80 @@ module ActiveRecord
23
23
  }
24
24
 
25
25
  unless (payload[:binds] || []).empty?
26
- log_payload[:binds] = binds = {}
27
- if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 0 && Rails::VERSION::TINY <= 2 # 5.0.0 - 5.0.2
28
- payload[:binds].each do |attr|
29
- attr_name, value = render_bind(attr)
30
- binds[attr_name] = value
26
+ log_payload[:binds] =
27
+ if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 0 && Rails::VERSION::TINY <= 2 # 5.0.0 - 5.0.2
28
+ bind_values_v5_0_0(payload)
29
+ elsif Rails::VERSION::MAJOR >= 5 && Rails::VERSION::MINOR <= 1 && (Rails::VERSION::MINOR == 0 || Rails::VERSION::TINY <= 4) # 5.0.3 - 5.1.4
30
+ bind_values_v5_0_3(payload)
31
+ elsif Rails::VERSION::MAJOR >= 5 # >= 5.1.5
32
+ bind_values_v5_1_5(payload)
33
+ elsif Rails.version.to_i >= 4 # 4.x
34
+ bind_values_v4(payload)
35
+ else # 3.x
36
+ bind_values_v3(payload)
31
37
  end
32
- elsif Rails::VERSION::MAJOR >= 5 && Rails::VERSION::MINOR <= 1 # 5.0.3 - 5.1.x
33
- casted_params = type_casted_binds(payload[:binds], payload[:type_casted_binds])
34
- payload[:binds].zip(casted_params).map { |attr, value|
35
- render_bind(attr, value)
36
- }
37
- elsif Rails::VERSION::MAJOR >= 5 # >= 5.2
38
- casted_params = type_casted_binds(payload[:type_casted_binds])
39
- payload[:binds].zip(casted_params).map do |attr, value|
40
- render_bind(attr, value)
41
- end
42
- elsif Rails.version.to_i >= 4 # 4.x
43
- payload[:binds].each do |col, v|
44
- attr_name, value = render_bind(col, v)
45
- binds[attr_name] = value
46
- end
47
- else # 3.x
48
- payload[:binds].each do |col,v|
49
- if col
50
- binds[col.name] = v
51
- else
52
- binds[nil] = v
53
- end
54
- end
55
- end
56
38
  end
57
39
  debug(log)
58
40
  end
59
41
 
42
+ private
43
+
44
+ def bind_values_v3(payload)
45
+ binds = {}
46
+ payload[:binds].each do |col, v|
47
+ if col
48
+ add_bind_value(binds, col.name, v)
49
+ else
50
+ binds[nil] = v
51
+ end
52
+ end
53
+ binds
54
+ end
55
+
56
+ def bind_values_v4(payload)
57
+ binds = {}
58
+ payload[:binds].each do |col, v|
59
+ attr_name, value = render_bind(col, v)
60
+ add_bind_value(binds, attr_name, value)
61
+ end
62
+ binds
63
+ end
64
+
65
+ def bind_values_v5_0_0(payload)
66
+ binds = {}
67
+ payload[:binds].each do |attr|
68
+ attr_name, value = render_bind(attr)
69
+ add_bind_value(binds, attr_name, value)
70
+ end
71
+ binds
72
+ end
73
+
74
+ def bind_values_v5_0_3(payload)
75
+ binds = {}
76
+ casted_params = type_casted_binds(payload[:binds], payload[:type_casted_binds])
77
+ payload[:binds].zip(casted_params).map do |attr, value|
78
+ attr_name, value = render_bind(attr, value)
79
+ add_bind_value(binds, attr_name, value)
80
+ end
81
+ binds
82
+ end
83
+
84
+ def bind_values_v5_1_5(payload)
85
+ binds = {}
86
+ casted_params = type_casted_binds(payload[:type_casted_binds])
87
+ payload[:binds].zip(casted_params).map do |attr, value|
88
+ attr_name, value = render_bind(attr, value)
89
+ add_bind_value(binds, attr_name, value)
90
+ end
91
+ binds
92
+ end
93
+
94
+ # When multiple values are received for a single bound field, it is converted into an array
95
+ def add_bind_value(binds, key, value)
96
+ key = key.downcase.to_sym
97
+ value = (Array(binds[key]) << value) if binds.key?(key)
98
+ binds[key] = value
99
+ end
100
+
60
101
  end
61
102
  end
@@ -1,3 +1,3 @@
1
1
  module RailsSemanticLogger #:nodoc
2
- VERSION = '4.2.0'
2
+ VERSION = '4.2.1'
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.2.0
4
+ version: 4.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reid Morrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-25 00:00:00.000000000 Z
11
+ date: 2018-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails