rails_semantic_logger 4.11.0 → 4.12.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: 6944c99a390bc385a4d5a83daea0fc340dbd4dd2913631ae3a812590ec1503e4
4
- data.tar.gz: ebb36106bde192de58b716077fc4c1b5c51d474ee9e86e5a93ef4a77fc25d1be
3
+ metadata.gz: 73a37ac27f2cf94d083cc75aa557a778f32e2de852b3be6447b072dc1da89047
4
+ data.tar.gz: 681f2145e71def6b336792fe3d581dfd89da6fd3ca471befcbd8ffa4f11abb50
5
5
  SHA512:
6
- metadata.gz: 1e1cf6df574f6dd146029407d80d2a4b51e1bfb222dbf511dbc6b540070e8d7432cff0eaf4cf94227b2d5440eb21c2ebab7222db774dd9408ebda613ae0df3bf
7
- data.tar.gz: 2da852f09a5417bc91e155f1bb80d9a1c50baa823cd39c46ee2ea7a9ecfa366f95b551c996a3a295d6074424224fd5aaf390c14c7f08b88effdcae31486d3bc4
6
+ metadata.gz: 8d299a14cb4c3eaf282e4bf502d8e60c2a36095b138c17969cf0a8f79b0431a731adbe8963ae2017bf429f12b7f42fe65d5c199a2c5f88e984a71d4605766bea
7
+ data.tar.gz: d837dc46c0dcd38b19dcf2a62c926c91ef1775542d55c8919d3a76db2e62764ab8675890238da78ab19b157f3b920e9d92257d5b2e347bb66d0c5a2bde60441f
@@ -14,12 +14,22 @@ module RailsSemanticLogger
14
14
 
15
15
  # Unused, but needed for Devise 401 status code monkey patch to still work.
16
16
  ::ActionController::Base.log_process_action(payload)
17
+
18
+ params = payload[:params]
17
19
 
18
- # According to PR https://github.com/reidmorrison/rails_semantic_logger/pull/37/files
19
- # payload[:params] is not always a Hash.
20
- payload[:params] = payload[:params].to_unsafe_h unless payload[:params].is_a?(Hash)
21
- payload[:params] = payload[:params].except(*INTERNAL_PARAMS)
22
- payload.delete(:params) if payload[:params].empty?
20
+ if params.kind_of?(Hash) || params.kind_of?(::ActionController::Parameters)
21
+ # According to PR https://github.com/reidmorrison/rails_semantic_logger/pull/37/files
22
+ # params is not always a Hash.
23
+ payload[:params] = params.to_unsafe_h unless params.is_a?(Hash)
24
+ payload[:params] = params.except(*INTERNAL_PARAMS)
25
+
26
+ if payload[:params].empty?
27
+ payload.delete(:params)
28
+ elsif params["file"]
29
+ # When logging to JSON the entire tempfile is logged, so convert it to a string.
30
+ payload[:params]["file"] = params["file"].inspect
31
+ end
32
+ end
23
33
 
24
34
  format = payload[:format]
25
35
  payload[:format] = format.to_s.upcase if format.is_a?(Symbol)
@@ -48,12 +58,6 @@ module RailsSemanticLogger
48
58
  payload.delete(:request)
49
59
  payload.delete(:response)
50
60
 
51
- params = payload[:params]
52
- if params
53
- # When logging to JSON the entire tempfile is logged, so convert it to a string.
54
- params["file"] = params["file"].inspect if params["file"]
55
- end
56
-
57
61
  {
58
62
  message: "Completed ##{payload[:action]}",
59
63
  duration: event.duration,
@@ -9,7 +9,7 @@ module RailsSemanticLogger
9
9
  message_id = event.payload[:message_id]
10
10
  duration = event.duration.round(1)
11
11
  if ex
12
- log_with_formatter event: event, log_duration: true, level: :error do |fmt|
12
+ log_with_formatter event: event, log_duration: true, level: :error do |fmt|
13
13
  {
14
14
  message: "Error delivering mail #{message_id} (#{duration}ms)",
15
15
  exception: ex
@@ -17,7 +17,7 @@ module RailsSemanticLogger
17
17
  end
18
18
  else
19
19
  message = begin
20
- if event.payload[:perform_deliveries]
20
+ if event.payload[:perform_deliveries]
21
21
  "Delivered mail #{message_id} (#{duration}ms)"
22
22
  else
23
23
  "Skipped delivery of mail #{message_id} as `perform_deliveries` is false"
@@ -1,7 +1,4 @@
1
1
  require "rails"
2
- require "action_controller/log_subscriber"
3
- require "action_view/log_subscriber"
4
- require "action_mailer/log_subscriber"
5
2
  require "rails_semantic_logger/options"
6
3
 
7
4
  module RailsSemanticLogger
@@ -111,7 +108,14 @@ module RailsSemanticLogger
111
108
  Resque.logger = SemanticLogger[Resque] if defined?(Resque) && Resque.respond_to?(:logger=)
112
109
 
113
110
  # Replace the Sidekiq logger
114
- Sidekiq.logger = SemanticLogger[Sidekiq] if defined?(Sidekiq) && Sidekiq.respond_to?(:logger=)
111
+ if defined?(Sidekiq)
112
+ if Sidekiq.respond_to?(:logger=)
113
+ Sidekiq.logger = SemanticLogger[Sidekiq]
114
+ elsif Sidekiq::VERSION[0..1] == '7.'
115
+ method = Sidekiq.server? ? :configure_server : :configure_client
116
+ Sidekiq.public_send(method) { |cfg| cfg.logger = SemanticLogger[Sidekiq] }
117
+ end
118
+ end
115
119
 
116
120
  # Replace the Sidetiq logger
117
121
  Sidetiq.logger = SemanticLogger[Sidetiq] if defined?(Sidetiq) && Sidetiq.respond_to?(:logger=)
@@ -186,26 +190,38 @@ module RailsSemanticLogger
186
190
  end
187
191
 
188
192
  # Action View
189
- RailsSemanticLogger::ActionView::LogSubscriber.rendered_log_level = :info if config.rails_semantic_logger.rendered
190
- RailsSemanticLogger.swap_subscriber(
191
- ::ActionView::LogSubscriber,
192
- RailsSemanticLogger::ActionView::LogSubscriber,
193
- :action_view
194
- )
193
+ if defined?(::ActionView)
194
+ require "action_view/log_subscriber"
195
+
196
+ RailsSemanticLogger::ActionView::LogSubscriber.rendered_log_level = :info if config.rails_semantic_logger.rendered
197
+ RailsSemanticLogger.swap_subscriber(
198
+ ::ActionView::LogSubscriber,
199
+ RailsSemanticLogger::ActionView::LogSubscriber,
200
+ :action_view
201
+ )
202
+ end
195
203
 
196
204
  # Action Controller
197
- RailsSemanticLogger.swap_subscriber(
198
- ::ActionController::LogSubscriber,
199
- RailsSemanticLogger::ActionController::LogSubscriber,
200
- :action_controller
201
- )
205
+ if defined?(::ActionController)
206
+ require "action_controller/log_subscriber"
207
+
208
+ RailsSemanticLogger.swap_subscriber(
209
+ ::ActionController::LogSubscriber,
210
+ RailsSemanticLogger::ActionController::LogSubscriber,
211
+ :action_controller
212
+ )
213
+ end
202
214
 
203
215
  # Action Mailer
204
- RailsSemanticLogger.swap_subscriber(
205
- ::ActionMailer::LogSubscriber,
206
- RailsSemanticLogger::ActionMailer::LogSubscriber,
207
- :action_mailer
208
- )
216
+ if defined?(::ActionMailer)
217
+ require "action_mailer/log_subscriber"
218
+
219
+ RailsSemanticLogger.swap_subscriber(
220
+ ::ActionMailer::LogSubscriber,
221
+ RailsSemanticLogger::ActionMailer::LogSubscriber,
222
+ :action_mailer
223
+ )
224
+ end
209
225
  end
210
226
 
211
227
  #
@@ -35,16 +35,18 @@ module RailsSemanticLogger
35
35
  @started_request_log_level = :debug
36
36
 
37
37
  def call_app(request, env)
38
- instrumenter = ActiveSupport::Notifications.instrumenter
39
- instrumenter.start "request.action_dispatch", request: request
38
+ instrumenter = ActiveSupport::Notifications.instrumenter
39
+ instrumenter_state = instrumenter.start "request.action_dispatch", request: request
40
+ instrumenter_finish = -> () {
41
+ instrumenter.finish_with_state(instrumenter_state, "request.action_dispatch", request: request)
42
+ }
40
43
 
41
44
  logger.send(self.class.started_request_log_level) { started_request_message(request) }
42
-
43
45
  status, headers, body = @app.call(env)
44
- body = ::Rack::BodyProxy.new(body) { finish(request) }
46
+ body = ::Rack::BodyProxy.new(body, &instrumenter_finish)
45
47
  [status, headers, body]
46
48
  rescue Exception
47
- finish(request)
49
+ instrumenter_finish.call
48
50
  raise
49
51
  end
50
52
 
@@ -90,11 +92,6 @@ module RailsSemanticLogger
90
92
  tagged
91
93
  end
92
94
 
93
- def finish(request)
94
- instrumenter = ActiveSupport::Notifications.instrumenter
95
- instrumenter.finish "request.action_dispatch", request: request
96
- end
97
-
98
95
  def logger
99
96
  self.class.logger
100
97
  end
@@ -1,3 +1,3 @@
1
1
  module RailsSemanticLogger
2
- VERSION = "4.11.0".freeze
2
+ VERSION = "4.12.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.11.0
4
+ version: 4.12.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-11-10 00:00:00.000000000 Z
11
+ date: 2023-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '4.9'
47
+ version: '4.13'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '4.9'
54
+ version: '4.13'
55
55
  description:
56
56
  email:
57
57
  executables: []
@@ -86,7 +86,11 @@ files:
86
86
  homepage: https://logger.rocketjob.io
87
87
  licenses:
88
88
  - Apache-2.0
89
- metadata: {}
89
+ metadata:
90
+ bug_tracker_uri: https://github.com/reidmorrison/rails_semantic_logger/issues
91
+ documentation_uri: https://logger.rocketjob.io
92
+ source_code_uri: https://github.com/reidmorrison/rails_semantic_logger/tree/4.12.0
93
+ rubygems_mfa_required: 'true'
90
94
  post_install_message:
91
95
  rdoc_options: []
92
96
  require_paths:
@@ -102,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
106
  - !ruby/object:Gem::Version
103
107
  version: '0'
104
108
  requirements: []
105
- rubygems_version: 3.1.6
109
+ rubygems_version: 3.4.9
106
110
  signing_key:
107
111
  specification_version: 4
108
112
  summary: Feature rich logging framework that replaces the Rails logger.