rails_semantic_logger 4.11.0 → 4.14.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 +4 -4
- data/lib/rails_semantic_logger/action_controller/log_subscriber.rb +18 -12
- data/lib/rails_semantic_logger/action_mailer/log_subscriber.rb +12 -14
- data/lib/rails_semantic_logger/action_view/log_subscriber.rb +51 -6
- data/lib/rails_semantic_logger/active_job/log_subscriber.rb +35 -5
- data/lib/rails_semantic_logger/active_record/log_subscriber.rb +1 -3
- data/lib/rails_semantic_logger/engine.rb +43 -25
- data/lib/rails_semantic_logger/extensions/active_job/logging.rb +5 -1
- data/lib/rails_semantic_logger/extensions/active_support/log_subscriber.rb +13 -0
- data/lib/rails_semantic_logger/extensions/active_support/logger.rb +11 -8
- data/lib/rails_semantic_logger/extensions/rackup/server.rb +12 -0
- data/lib/rails_semantic_logger/extensions/rails/server.rb +1 -1
- data/lib/rails_semantic_logger/rack/logger.rb +7 -10
- data/lib/rails_semantic_logger/version.rb +1 -1
- data/lib/rails_semantic_logger.rb +16 -3
- metadata +12 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b41a1fee07d074d18bcaed7538592f123ecbbbe0f232b52cbca96133654ac256
|
|
4
|
+
data.tar.gz: df2d6ef10cb8aa051f56a3b916064d1c51afcc3c9ef6f834c2c26be5a3dfc9b4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 70dec27d9976ae2edfc028bdfd03f51b3eade4cf1562681096ba3a882e2f0aacc9fba893cacd5ac7604f3810b2d6e3b880d2411d78a4372ad5b53ab579e41878
|
|
7
|
+
data.tar.gz: 635c69136356a8c3ad62a81e0b2db7e397031878619c381fe52240405c2c0b720b9f4900fc2d2ae886d8c23943f8ebd1649444b35357c6178016bb99f036e7dd
|
|
@@ -15,11 +15,21 @@ module RailsSemanticLogger
|
|
|
15
15
|
# Unused, but needed for Devise 401 status code monkey patch to still work.
|
|
16
16
|
::ActionController::Base.log_process_action(payload)
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
params = payload[:params]
|
|
19
|
+
|
|
20
|
+
if params.is_a?(Hash) || params.is_a?(::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,
|
|
@@ -75,7 +79,9 @@ module RailsSemanticLogger
|
|
|
75
79
|
end
|
|
76
80
|
|
|
77
81
|
def send_data(event)
|
|
78
|
-
controller_logger(event).info(message:
|
|
82
|
+
controller_logger(event).info(message: "Sent data",
|
|
83
|
+
payload: {file_name: event.payload[:filename]},
|
|
84
|
+
duration: event.duration)
|
|
79
85
|
end
|
|
80
86
|
|
|
81
87
|
def unpermitted_parameters(event)
|
|
@@ -9,22 +9,22 @@ module RailsSemanticLogger
|
|
|
9
9
|
message_id = event.payload[:message_id]
|
|
10
10
|
duration = event.duration.round(1)
|
|
11
11
|
if ex
|
|
12
|
-
|
|
12
|
+
log_with_formatter event: event, log_duration: true, level: :error do |_fmt|
|
|
13
13
|
{
|
|
14
|
-
message:
|
|
14
|
+
message: "Error delivering mail #{message_id} (#{duration}ms)",
|
|
15
15
|
exception: ex
|
|
16
16
|
}
|
|
17
17
|
end
|
|
18
18
|
else
|
|
19
|
-
message =
|
|
20
|
-
|
|
19
|
+
message =
|
|
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"
|
|
24
24
|
end
|
|
25
|
-
|
|
26
|
-
log_with_formatter event: event, log_duration: true do |
|
|
27
|
-
{
|
|
25
|
+
|
|
26
|
+
log_with_formatter event: event, log_duration: true do |_fmt|
|
|
27
|
+
{message: message}
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
end
|
|
@@ -34,8 +34,8 @@ module RailsSemanticLogger
|
|
|
34
34
|
mailer = event.payload[:mailer]
|
|
35
35
|
action = event.payload[:action]
|
|
36
36
|
duration = event.duration.round(1)
|
|
37
|
-
log_with_formatter event: event do |
|
|
38
|
-
{
|
|
37
|
+
log_with_formatter event: event do |_fmt|
|
|
38
|
+
{message: "#{mailer}##{action}: processed outbound mail in #{duration}ms"}
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
|
|
@@ -74,8 +74,6 @@ module RailsSemanticLogger
|
|
|
74
74
|
event.payload[:date].to_time.utc
|
|
75
75
|
elsif event.payload[:date].is_a?(String)
|
|
76
76
|
Time.parse(date).utc
|
|
77
|
-
else
|
|
78
|
-
nil
|
|
79
77
|
end
|
|
80
78
|
end
|
|
81
79
|
|
|
@@ -92,10 +90,10 @@ module RailsSemanticLogger
|
|
|
92
90
|
end
|
|
93
91
|
|
|
94
92
|
def formatted_args
|
|
95
|
-
if defined?(mailer.
|
|
93
|
+
if defined?(mailer.constantize.log_arguments?) && !mailer.constantize.log_arguments?
|
|
96
94
|
""
|
|
97
|
-
|
|
98
|
-
JSON.pretty_generate(event.payload[:args].map { |arg| format(arg) })
|
|
95
|
+
elsif event.payload[:args].present?
|
|
96
|
+
JSON.pretty_generate(event.payload[:args].map { |arg| format(arg) })
|
|
99
97
|
end
|
|
100
98
|
end
|
|
101
99
|
|
|
@@ -22,7 +22,7 @@ module RailsSemanticLogger
|
|
|
22
22
|
payload = {
|
|
23
23
|
template: from_rails_root(event.payload[:identifier])
|
|
24
24
|
}
|
|
25
|
-
payload[:within]
|
|
25
|
+
payload[:within] = from_rails_root(event.payload[:layout]) if event.payload[:layout]
|
|
26
26
|
payload[:allocations] = event.allocations if event.respond_to?(:allocations)
|
|
27
27
|
|
|
28
28
|
logger.measure(
|
|
@@ -39,8 +39,8 @@ module RailsSemanticLogger
|
|
|
39
39
|
payload = {
|
|
40
40
|
partial: from_rails_root(event.payload[:identifier])
|
|
41
41
|
}
|
|
42
|
-
payload[:within]
|
|
43
|
-
payload[:cache]
|
|
42
|
+
payload[:within] = from_rails_root(event.payload[:layout]) if event.payload[:layout]
|
|
43
|
+
payload[:cache] = event.payload[:cache_hit] unless event.payload[:cache_hit].nil?
|
|
44
44
|
payload[:allocations] = event.allocations if event.respond_to?(:allocations)
|
|
45
45
|
|
|
46
46
|
logger.measure(
|
|
@@ -60,7 +60,7 @@ module RailsSemanticLogger
|
|
|
60
60
|
template: from_rails_root(identifier),
|
|
61
61
|
count: event.payload[:count]
|
|
62
62
|
}
|
|
63
|
-
payload[:cache_hits]
|
|
63
|
+
payload[:cache_hits] = event.payload[:cache_hits] if event.payload[:cache_hits]
|
|
64
64
|
payload[:allocations] = event.allocations if event.respond_to?(:allocations)
|
|
65
65
|
|
|
66
66
|
logger.measure(
|
|
@@ -72,16 +72,61 @@ module RailsSemanticLogger
|
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
def start(name, id, payload)
|
|
75
|
-
if
|
|
75
|
+
if ["render_template.action_view", "render_layout.action_view"].include?(name) && should_log?
|
|
76
|
+
qualifier = " layout" if name == "render_layout.action_view"
|
|
76
77
|
payload = {template: from_rails_root(payload[:identifier])}
|
|
77
78
|
payload[:within] = from_rails_root(payload[:layout]) if payload[:layout]
|
|
78
79
|
|
|
79
|
-
logger.send(self.class.rendered_log_level, message: "Rendering", payload: payload)
|
|
80
|
+
logger.send(self.class.rendered_log_level, message: "Rendering#{qualifier}", payload: payload)
|
|
80
81
|
end
|
|
81
82
|
|
|
82
83
|
super
|
|
83
84
|
end
|
|
84
85
|
|
|
86
|
+
if (Rails::VERSION::MAJOR == 7 && Rails::VERSION::MINOR >= 1) || Rails::VERSION::MAJOR > 7
|
|
87
|
+
class Start
|
|
88
|
+
def start(name, _id, payload)
|
|
89
|
+
return unless %w[render_template.action_view render_layout.action_view].include?(name)
|
|
90
|
+
|
|
91
|
+
qualifier = " layout" if name == "render_layout.action_view"
|
|
92
|
+
payload = {template: from_rails_root(payload[:identifier])}
|
|
93
|
+
payload[:within] = from_rails_root(payload[:layout]) if payload[:layout]
|
|
94
|
+
|
|
95
|
+
logger.debug(message: "Rendering#{qualifier}", payload: payload)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def finish(name, id, payload)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
private
|
|
102
|
+
|
|
103
|
+
def from_rails_root(string)
|
|
104
|
+
string = string.sub(rails_root, "")
|
|
105
|
+
string.sub!(VIEWS_PATTERN, "")
|
|
106
|
+
string
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def rails_root
|
|
110
|
+
@root ||= "#{Rails.root}/"
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def logger
|
|
114
|
+
@logger ||= SemanticLogger["ActionView"]
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def self.attach_to(*)
|
|
119
|
+
ActiveSupport::Notifications.unsubscribe("render_template.action_view")
|
|
120
|
+
ActiveSupport::Notifications.unsubscribe("render_layout.action_view")
|
|
121
|
+
ActiveSupport::Notifications.subscribe("render_template.action_view",
|
|
122
|
+
RailsSemanticLogger::ActionView::LogSubscriber::Start.new)
|
|
123
|
+
ActiveSupport::Notifications.subscribe("render_layout.action_view",
|
|
124
|
+
RailsSemanticLogger::ActionView::LogSubscriber::Start.new)
|
|
125
|
+
|
|
126
|
+
super
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
85
130
|
private
|
|
86
131
|
|
|
87
132
|
@logger = SemanticLogger["ActionView"]
|
|
@@ -4,14 +4,44 @@ module RailsSemanticLogger
|
|
|
4
4
|
module ActiveJob
|
|
5
5
|
class LogSubscriber < ::ActiveSupport::LogSubscriber
|
|
6
6
|
def enqueue(event)
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
ex = event.payload[:exception_object]
|
|
8
|
+
|
|
9
|
+
if ex
|
|
10
|
+
log_with_formatter level: :error, event: event do |fmt|
|
|
11
|
+
{
|
|
12
|
+
message: "Failed enqueuing #{fmt.job_info} (#{ex.class} (#{ex.message})",
|
|
13
|
+
exception: ex
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
elsif event.payload[:aborted]
|
|
17
|
+
log_with_formatter level: :info, event: event do |fmt|
|
|
18
|
+
{message: "Failed enqueuing #{fmt.job_info}, a before_enqueue callback halted the enqueuing execution."}
|
|
19
|
+
end
|
|
20
|
+
else
|
|
21
|
+
log_with_formatter event: event do |fmt|
|
|
22
|
+
{message: "Enqueued #{fmt.job_info}"}
|
|
23
|
+
end
|
|
9
24
|
end
|
|
10
25
|
end
|
|
11
26
|
|
|
12
27
|
def enqueue_at(event)
|
|
13
|
-
|
|
14
|
-
|
|
28
|
+
ex = event.payload[:exception_object]
|
|
29
|
+
|
|
30
|
+
if ex
|
|
31
|
+
log_with_formatter level: :error, event: event do |fmt|
|
|
32
|
+
{
|
|
33
|
+
message: "Failed enqueuing #{fmt.job_info} (#{ex.class} (#{ex.message})",
|
|
34
|
+
exception: ex
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
elsif event.payload[:aborted]
|
|
38
|
+
log_with_formatter level: :info, event: event do |fmt|
|
|
39
|
+
{message: "Failed enqueuing #{fmt.job_info}, a before_enqueue callback halted the enqueuing execution."}
|
|
40
|
+
end
|
|
41
|
+
else
|
|
42
|
+
log_with_formatter event: event do |fmt|
|
|
43
|
+
{message: "Enqueued #{fmt.job_info} at #{fmt.scheduled_at}"}
|
|
44
|
+
end
|
|
15
45
|
end
|
|
16
46
|
end
|
|
17
47
|
|
|
@@ -26,7 +56,7 @@ module RailsSemanticLogger
|
|
|
26
56
|
if ex
|
|
27
57
|
log_with_formatter event: event, log_duration: true, level: :error do |fmt|
|
|
28
58
|
{
|
|
29
|
-
message:
|
|
59
|
+
message: "Error performing #{fmt.job_info} in #{event.duration.round(2)}ms",
|
|
30
60
|
exception: ex
|
|
31
61
|
}
|
|
32
62
|
end
|
|
@@ -169,9 +169,7 @@ module RailsSemanticLogger
|
|
|
169
169
|
def render_bind_v6_1(attr, value)
|
|
170
170
|
case attr
|
|
171
171
|
when ActiveModel::Attribute
|
|
172
|
-
if attr.type.binary? && attr.value
|
|
173
|
-
value = "<#{attr.value_for_database.to_s.bytesize} bytes of binary data>"
|
|
174
|
-
end
|
|
172
|
+
value = "<#{attr.value_for_database.to_s.bytesize} bytes of binary data>" if attr.type.binary? && attr.value
|
|
175
173
|
when Array
|
|
176
174
|
attr = attr.first
|
|
177
175
|
else
|
|
@@ -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
|
|
@@ -80,7 +77,7 @@ module RailsSemanticLogger
|
|
|
80
77
|
logger = SemanticLogger[Rails]
|
|
81
78
|
logger.warn(
|
|
82
79
|
"Rails Error: Unable to access log file. Please ensure that #{path} exists and is chmod 0666. " \
|
|
83
|
-
|
|
80
|
+
"The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.",
|
|
84
81
|
e
|
|
85
82
|
)
|
|
86
83
|
logger
|
|
@@ -111,10 +108,17 @@ module RailsSemanticLogger
|
|
|
111
108
|
Resque.logger = SemanticLogger[Resque] if defined?(Resque) && Resque.respond_to?(:logger=)
|
|
112
109
|
|
|
113
110
|
# Replace the Sidekiq logger
|
|
114
|
-
|
|
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
|
-
Sidetiq.logger
|
|
121
|
+
Sidetiq.logger = SemanticLogger[Sidetiq] if defined?(Sidetiq) && Sidetiq.respond_to?(:logger=)
|
|
118
122
|
|
|
119
123
|
# Replace the DelayedJob logger
|
|
120
124
|
if defined?(Delayed::Worker)
|
|
@@ -123,7 +127,7 @@ module RailsSemanticLogger
|
|
|
123
127
|
end
|
|
124
128
|
|
|
125
129
|
# Replace the Bugsnag logger
|
|
126
|
-
Bugsnag.configure { |config| config.logger = SemanticLogger[Bugsnag] } if defined?(Bugsnag)
|
|
130
|
+
Bugsnag.configure(false) { |config| config.logger = SemanticLogger[Bugsnag] } if defined?(Bugsnag)
|
|
127
131
|
|
|
128
132
|
# Set the IOStreams PGP logger
|
|
129
133
|
IOStreams::Pgp.logger = SemanticLogger["IOStreams::Pgp"] if defined?(IOStreams)
|
|
@@ -134,12 +138,14 @@ module RailsSemanticLogger
|
|
|
134
138
|
config = Rails.application.config
|
|
135
139
|
|
|
136
140
|
# Replace the Bugsnag logger
|
|
137
|
-
Bugsnag.configure { |bugsnag_config| bugsnag_config.logger = SemanticLogger[Bugsnag] } if defined?(Bugsnag)
|
|
141
|
+
Bugsnag.configure(false) { |bugsnag_config| bugsnag_config.logger = SemanticLogger[Bugsnag] } if defined?(Bugsnag)
|
|
138
142
|
|
|
139
143
|
# Rails Patches
|
|
140
144
|
require("rails_semantic_logger/extensions/action_cable/tagged_logger_proxy") if defined?(::ActionCable)
|
|
141
145
|
require("rails_semantic_logger/extensions/action_controller/live") if defined?(::ActionController::Live)
|
|
142
|
-
|
|
146
|
+
if defined?(::ActionDispatch::DebugExceptions)
|
|
147
|
+
require("rails_semantic_logger/extensions/action_dispatch/debug_exceptions")
|
|
148
|
+
end
|
|
143
149
|
if defined?(::ActionView::StreamingTemplateRenderer::Body)
|
|
144
150
|
require("rails_semantic_logger/extensions/action_view/streaming_template_renderer")
|
|
145
151
|
end
|
|
@@ -186,26 +192,38 @@ module RailsSemanticLogger
|
|
|
186
192
|
end
|
|
187
193
|
|
|
188
194
|
# Action View
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
RailsSemanticLogger::ActionView::LogSubscriber
|
|
193
|
-
|
|
194
|
-
|
|
195
|
+
if defined?(::ActionView)
|
|
196
|
+
require "action_view/log_subscriber"
|
|
197
|
+
|
|
198
|
+
RailsSemanticLogger::ActionView::LogSubscriber.rendered_log_level = :info if config.rails_semantic_logger.rendered
|
|
199
|
+
RailsSemanticLogger.swap_subscriber(
|
|
200
|
+
::ActionView::LogSubscriber,
|
|
201
|
+
RailsSemanticLogger::ActionView::LogSubscriber,
|
|
202
|
+
:action_view
|
|
203
|
+
)
|
|
204
|
+
end
|
|
195
205
|
|
|
196
206
|
# Action Controller
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
207
|
+
if defined?(::ActionController)
|
|
208
|
+
require "action_controller/log_subscriber"
|
|
209
|
+
|
|
210
|
+
RailsSemanticLogger.swap_subscriber(
|
|
211
|
+
::ActionController::LogSubscriber,
|
|
212
|
+
RailsSemanticLogger::ActionController::LogSubscriber,
|
|
213
|
+
:action_controller
|
|
214
|
+
)
|
|
215
|
+
end
|
|
202
216
|
|
|
203
217
|
# Action Mailer
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
218
|
+
if defined?(::ActionMailer)
|
|
219
|
+
require "action_mailer/log_subscriber"
|
|
220
|
+
|
|
221
|
+
RailsSemanticLogger.swap_subscriber(
|
|
222
|
+
::ActionMailer::LogSubscriber,
|
|
223
|
+
RailsSemanticLogger::ActionMailer::LogSubscriber,
|
|
224
|
+
:action_mailer
|
|
225
|
+
)
|
|
226
|
+
end
|
|
209
227
|
end
|
|
210
228
|
|
|
211
229
|
#
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
if ActiveSupport::VERSION::STRING == "7.1.1"
|
|
2
|
+
require "active_support/log_subscriber"
|
|
3
|
+
|
|
4
|
+
module ActiveSupport
|
|
5
|
+
class LogSubscriber
|
|
6
|
+
# @override Rails 7.1
|
|
7
|
+
def silenced?(event)
|
|
8
|
+
native_log_level = @event_levels.fetch(event, ::Logger::Severity::FATAL)
|
|
9
|
+
logger.nil? || SemanticLogger::Levels.index(logger.level) > SemanticLogger::Levels.index(native_log_level)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -4,20 +4,23 @@ module ActiveSupport
|
|
|
4
4
|
# More hacks to try and stop Rails from being it's own worst enemy.
|
|
5
5
|
class Logger
|
|
6
6
|
class << self
|
|
7
|
-
undef :logger_outputs_to
|
|
7
|
+
undef :logger_outputs_to?
|
|
8
|
+
|
|
9
|
+
# Prevent broadcasting since SemanticLogger already supports multiple loggers
|
|
10
|
+
if method_defined?(:broadcast)
|
|
11
|
+
undef :broadcast
|
|
12
|
+
def broadcast(_logger)
|
|
13
|
+
Module.new
|
|
14
|
+
end
|
|
15
|
+
end
|
|
8
16
|
end
|
|
9
17
|
|
|
10
18
|
# Prevent Console from trying to merge loggers
|
|
11
|
-
def self.logger_outputs_to?(*
|
|
19
|
+
def self.logger_outputs_to?(*_args)
|
|
12
20
|
true
|
|
13
21
|
end
|
|
14
22
|
|
|
15
|
-
|
|
16
|
-
def self.broadcast(logger)
|
|
17
|
-
Module.new
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def self.new(*args, **kwargs)
|
|
23
|
+
def self.new(*_args, **_kwargs)
|
|
21
24
|
SemanticLogger[self]
|
|
22
25
|
end
|
|
23
26
|
end
|
|
@@ -35,16 +35,18 @@ module RailsSemanticLogger
|
|
|
35
35
|
@started_request_log_level = :debug
|
|
36
36
|
|
|
37
37
|
def call_app(request, env)
|
|
38
|
-
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 = lambda {
|
|
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
|
|
46
|
+
body = ::Rack::BodyProxy.new(body, &instrumenter_finish)
|
|
45
47
|
[status, headers, body]
|
|
46
48
|
rescue Exception
|
|
47
|
-
|
|
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
|
|
@@ -6,21 +6,27 @@ module RailsSemanticLogger
|
|
|
6
6
|
module ActionController
|
|
7
7
|
autoload :LogSubscriber, "rails_semantic_logger/action_controller/log_subscriber"
|
|
8
8
|
end
|
|
9
|
+
|
|
9
10
|
module ActionMailer
|
|
10
11
|
autoload :LogSubscriber, "rails_semantic_logger/action_mailer/log_subscriber"
|
|
11
12
|
end
|
|
13
|
+
|
|
12
14
|
module ActionView
|
|
13
15
|
autoload :LogSubscriber, "rails_semantic_logger/action_view/log_subscriber"
|
|
14
16
|
end
|
|
17
|
+
|
|
15
18
|
module ActiveJob
|
|
16
19
|
autoload :LogSubscriber, "rails_semantic_logger/active_job/log_subscriber"
|
|
17
20
|
end
|
|
21
|
+
|
|
18
22
|
module ActiveRecord
|
|
19
23
|
autoload :LogSubscriber, "rails_semantic_logger/active_record/log_subscriber"
|
|
20
24
|
end
|
|
25
|
+
|
|
21
26
|
module Rack
|
|
22
27
|
autoload :Logger, "rails_semantic_logger/rack/logger"
|
|
23
28
|
end
|
|
29
|
+
|
|
24
30
|
module DelayedJob
|
|
25
31
|
autoload :Plugin, "rails_semantic_logger/delayed_job/plugin"
|
|
26
32
|
end
|
|
@@ -48,9 +54,11 @@ module RailsSemanticLogger
|
|
|
48
54
|
end
|
|
49
55
|
|
|
50
56
|
def self.subscriber_patterns(subscriber)
|
|
51
|
-
subscriber.patterns.respond_to?(:keys)
|
|
52
|
-
subscriber.patterns.keys
|
|
57
|
+
if subscriber.patterns.respond_to?(:keys)
|
|
58
|
+
subscriber.patterns.keys
|
|
59
|
+
else
|
|
53
60
|
subscriber.patterns
|
|
61
|
+
end
|
|
54
62
|
end
|
|
55
63
|
|
|
56
64
|
private_class_method :subscriber_patterns, :unattach
|
|
@@ -58,4 +66,9 @@ end
|
|
|
58
66
|
|
|
59
67
|
require("rails_semantic_logger/extensions/mongoid/config") if defined?(Mongoid)
|
|
60
68
|
require("rails_semantic_logger/extensions/active_support/logger") if defined?(ActiveSupport::Logger)
|
|
61
|
-
require("rails_semantic_logger/extensions/
|
|
69
|
+
require("rails_semantic_logger/extensions/active_support/log_subscriber") if defined?(ActiveSupport::LogSubscriber)
|
|
70
|
+
if defined?(Rackup::Server)
|
|
71
|
+
require("rails_semantic_logger/extensions/rackup/server")
|
|
72
|
+
elsif defined?(Rack::Server)
|
|
73
|
+
require("rails_semantic_logger/extensions/rack/server")
|
|
74
|
+
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
|
+
version: 4.14.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:
|
|
11
|
+
date: 2023-11-16 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.
|
|
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.
|
|
54
|
+
version: '4.13'
|
|
55
55
|
description:
|
|
56
56
|
email:
|
|
57
57
|
executables: []
|
|
@@ -75,10 +75,12 @@ files:
|
|
|
75
75
|
- lib/rails_semantic_logger/extensions/action_view/streaming_template_renderer.rb
|
|
76
76
|
- lib/rails_semantic_logger/extensions/active_job/logging.rb
|
|
77
77
|
- lib/rails_semantic_logger/extensions/active_model_serializers/logging.rb
|
|
78
|
+
- lib/rails_semantic_logger/extensions/active_support/log_subscriber.rb
|
|
78
79
|
- lib/rails_semantic_logger/extensions/active_support/logger.rb
|
|
79
80
|
- lib/rails_semantic_logger/extensions/active_support/tagged_logging.rb
|
|
80
81
|
- lib/rails_semantic_logger/extensions/mongoid/config.rb
|
|
81
82
|
- lib/rails_semantic_logger/extensions/rack/server.rb
|
|
83
|
+
- lib/rails_semantic_logger/extensions/rackup/server.rb
|
|
82
84
|
- lib/rails_semantic_logger/extensions/rails/server.rb
|
|
83
85
|
- lib/rails_semantic_logger/options.rb
|
|
84
86
|
- lib/rails_semantic_logger/rack/logger.rb
|
|
@@ -86,7 +88,11 @@ files:
|
|
|
86
88
|
homepage: https://logger.rocketjob.io
|
|
87
89
|
licenses:
|
|
88
90
|
- Apache-2.0
|
|
89
|
-
metadata:
|
|
91
|
+
metadata:
|
|
92
|
+
bug_tracker_uri: https://github.com/reidmorrison/rails_semantic_logger/issues
|
|
93
|
+
documentation_uri: https://logger.rocketjob.io
|
|
94
|
+
source_code_uri: https://github.com/reidmorrison/rails_semantic_logger/tree/v4.14.0
|
|
95
|
+
rubygems_mfa_required: 'true'
|
|
90
96
|
post_install_message:
|
|
91
97
|
rdoc_options: []
|
|
92
98
|
require_paths:
|
|
@@ -102,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
102
108
|
- !ruby/object:Gem::Version
|
|
103
109
|
version: '0'
|
|
104
110
|
requirements: []
|
|
105
|
-
rubygems_version: 3.
|
|
111
|
+
rubygems_version: 3.4.9
|
|
106
112
|
signing_key:
|
|
107
113
|
specification_version: 4
|
|
108
114
|
summary: Feature rich logging framework that replaces the Rails logger.
|