epilog 0.8.0 → 0.9.2
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/CHANGELOG.md +15 -0
- data/lib/epilog/filter/blacklist.rb +1 -1
- data/lib/epilog/filter/filter_parameters.rb +2 -2
- data/lib/epilog/mock_logger.rb +2 -2
- data/lib/epilog/rails/action_controller_subscriber.rb +2 -2
- data/lib/epilog/rails/action_view_subscriber.rb +1 -1
- data/lib/epilog/rails/active_job_subscriber.rb +1 -1
- data/lib/epilog/rails/active_record_subscriber.rb +1 -1
- data/lib/epilog/rails/ext/action_controller.rb +9 -11
- data/lib/epilog/rails/ext/active_support_logger.rb +16 -11
- data/lib/epilog/rails/ext/event_delegate.rb +7 -4
- data/lib/epilog/rails/railtie.rb +57 -17
- data/lib/epilog/version.rb +1 -1
- metadata +17 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e0f45daf54940c2e7449ae321341278f537f642429728a646339d0ad057ff933
|
|
4
|
+
data.tar.gz: ffade4ca680a3908a8d9c6c5912647881420d217dfeffbfd4e843195df62e30c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 60d208d4fa4e7bf3b8948e2888bda13ed4cf052bb23719f9fcc8e510166a8486eb0318b668377b388e732b932ba756a76aa6d4295fbda517c44bb506c6b0a381
|
|
7
|
+
data.tar.gz: dbe0e0a0d5dcd03b20fa0ef1ea87241745dba275e2297d9cba1cd34135b30bc602bf9aac1e9994070696bcd36b9e2b6343d8dff9dadc658285fe95a9461c9d16
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.9.2
|
|
4
|
+
|
|
5
|
+
- Fix double log issue in Rails 7.1+
|
|
6
|
+
|
|
7
|
+
## 0.9.1
|
|
8
|
+
|
|
9
|
+
- Remove Rails 8 from CI
|
|
10
|
+
|
|
11
|
+
## 0.9.0
|
|
12
|
+
|
|
13
|
+
- Add support for Rails 7.0 and Rails 7.1
|
|
14
|
+
- Drop support for Rails < 7.0
|
|
15
|
+
- Drop support for Ruby < 3.3
|
|
16
|
+
- Update dev and runtime dependencies
|
|
17
|
+
|
|
3
18
|
## 0.8.0
|
|
4
19
|
|
|
5
20
|
- Update license to MIT [#19](https://github.com/nullscreen/epilog/pull/19)
|
|
@@ -8,9 +8,9 @@ module Epilog
|
|
|
8
8
|
def filter_parameters
|
|
9
9
|
return @filter_parameters if @filter_parameters
|
|
10
10
|
|
|
11
|
-
filtered = ::Rails.application.config.filter_parameters.
|
|
11
|
+
filtered = ::Rails.application.config.filter_parameters.to_h do |p|
|
|
12
12
|
[p.to_s.downcase, true]
|
|
13
|
-
end
|
|
13
|
+
end
|
|
14
14
|
|
|
15
15
|
@filter_parameters = filtered if ::Rails.initialized?
|
|
16
16
|
filtered
|
data/lib/epilog/mock_logger.rb
CHANGED
|
@@ -88,7 +88,7 @@ module Epilog
|
|
|
88
88
|
info do
|
|
89
89
|
{
|
|
90
90
|
message: response_string(event),
|
|
91
|
-
request
|
|
91
|
+
request:,
|
|
92
92
|
response: response_hash(event),
|
|
93
93
|
metrics: process_metrics(event.payload[:metrics]
|
|
94
94
|
.merge(request_runtime: event.duration.round(2)))
|
|
@@ -158,7 +158,7 @@ module Epilog
|
|
|
158
158
|
|
|
159
159
|
def basic_message(event, message)
|
|
160
160
|
{
|
|
161
|
-
message
|
|
161
|
+
message:,
|
|
162
162
|
metrics: process_metrics(duration: event.duration)
|
|
163
163
|
}
|
|
164
164
|
end
|
|
@@ -6,7 +6,7 @@ module Epilog
|
|
|
6
6
|
IGNORE_PAYLOAD_NAMES = %w[SCHEMA EXPLAIN].freeze
|
|
7
7
|
|
|
8
8
|
def sql(event)
|
|
9
|
-
ActiveRecord::
|
|
9
|
+
ActiveRecord::RuntimeRegistry.sql_runtime = (ActiveRecord::RuntimeRegistry.sql_runtime || 0) + event.duration
|
|
10
10
|
|
|
11
11
|
return unless logger.debug?
|
|
12
12
|
|
|
@@ -5,29 +5,27 @@ module Epilog
|
|
|
5
5
|
def process_action(*)
|
|
6
6
|
epilog_instrument('request_received')
|
|
7
7
|
epilog_instrument('process_request') do |payload|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
payload[:metrics] = epilog_metrics
|
|
13
|
-
end
|
|
8
|
+
super
|
|
9
|
+
ensure
|
|
10
|
+
payload[:response] = response
|
|
11
|
+
payload[:metrics] = epilog_metrics
|
|
14
12
|
end
|
|
15
13
|
end
|
|
16
14
|
|
|
17
15
|
private
|
|
18
16
|
|
|
19
|
-
def epilog_instrument(name, &
|
|
17
|
+
def epilog_instrument(name, &)
|
|
20
18
|
ActiveSupport::Notifications.instrument(
|
|
21
19
|
"#{name}.action_controller",
|
|
22
20
|
epilog_payload,
|
|
23
|
-
&
|
|
21
|
+
&
|
|
24
22
|
)
|
|
25
23
|
end
|
|
26
24
|
|
|
27
25
|
def epilog_payload
|
|
28
26
|
{
|
|
29
|
-
request
|
|
30
|
-
response
|
|
27
|
+
request:,
|
|
28
|
+
response:,
|
|
31
29
|
controller: self.class.name,
|
|
32
30
|
action: action_name,
|
|
33
31
|
context: epilog_context
|
|
@@ -37,7 +35,7 @@ module Epilog
|
|
|
37
35
|
def epilog_metrics
|
|
38
36
|
{
|
|
39
37
|
db_runtime: try(:db_runtime),
|
|
40
|
-
view_runtime:
|
|
38
|
+
view_runtime:
|
|
41
39
|
}
|
|
42
40
|
end
|
|
43
41
|
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
# For Rails 7.1+, the broadcast_to patch is applied in the railtie's
|
|
4
|
+
# after_initialize block (see railtie.rb) to ensure the BroadcastLogger
|
|
5
|
+
# class is fully defined before we patch it.
|
|
6
|
+
if ::Rails.gem_version < Gem::Version.new('7.1')
|
|
7
|
+
module ActiveSupport
|
|
8
|
+
class Logger
|
|
9
|
+
# Rails uses this method to attach additional loggers to the main
|
|
10
|
+
# Rails.logger object when using the rails console or server. This results
|
|
11
|
+
# in extra unformatted log output in those cases. Prevent that by
|
|
12
|
+
# overriding the method with a stub. Examples can be found in
|
|
13
|
+
#
|
|
14
|
+
# - railties/lib/rails/commands/server.rb
|
|
15
|
+
# - active_record/lib/active_record/railtie.rb
|
|
16
|
+
def self.broadcast(*_args)
|
|
17
|
+
Module.new
|
|
18
|
+
end
|
|
14
19
|
end
|
|
15
20
|
end
|
|
16
21
|
end
|
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
module Epilog
|
|
4
4
|
module EventDelegateExt
|
|
5
5
|
# Rails has no public API to determine the delegate for an event
|
|
6
|
-
# object. Add
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
# object. Add these methods to allow checking the delegate.
|
|
7
|
+
def delegate
|
|
8
|
+
@delegate
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def delegates_to?(other)
|
|
12
|
+
@delegate == other
|
|
10
13
|
end
|
|
11
14
|
end
|
|
12
15
|
end
|
data/lib/epilog/rails/railtie.rb
CHANGED
|
@@ -44,8 +44,6 @@ module Epilog
|
|
|
44
44
|
]
|
|
45
45
|
|
|
46
46
|
initializer 'epilog.configure' do |app|
|
|
47
|
-
disable_rails_defaults
|
|
48
|
-
|
|
49
47
|
::Rails.logger ||= Logger.new($stdout)
|
|
50
48
|
|
|
51
49
|
app.config.epilog.subscriptions.each do |namespace|
|
|
@@ -57,28 +55,70 @@ module Epilog
|
|
|
57
55
|
end
|
|
58
56
|
end
|
|
59
57
|
|
|
60
|
-
|
|
58
|
+
# In Rails 7.1+, the server, console, and other components (like Sidekiq)
|
|
59
|
+
# call Rails.logger.broadcast_to() to add additional log destinations.
|
|
60
|
+
# This causes duplicate log lines and can lead to blocks being executed
|
|
61
|
+
# multiple times (via BroadcastLogger's method_missing delegation).
|
|
62
|
+
#
|
|
63
|
+
# This initializer runs AFTER :initialize_logger (which wraps the logger
|
|
64
|
+
# in a BroadcastLogger) but BEFORE any after_initialize hooks (where
|
|
65
|
+
# Sidekiq and others add their loggers). This ensures the no-op is in
|
|
66
|
+
# place before anyone tries to call broadcast_to.
|
|
67
|
+
initializer 'epilog.prevent_broadcast', after: :initialize_logger do
|
|
68
|
+
if ::Rails.gem_version >= Gem::Version.new('7.1') && ::Rails.logger
|
|
69
|
+
::Rails.logger.define_singleton_method(:broadcast_to) { |*| nil }
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# In Rails 7.1+, ActionView::LogSubscriber::Start are attached late
|
|
74
|
+
# in the initialization process, so we need to disable them after
|
|
75
|
+
# initialization completes
|
|
76
|
+
config.after_initialize do
|
|
77
|
+
disable_rails_defaults
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
class << self
|
|
81
|
+
private
|
|
61
82
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
83
|
+
def disable_rails_defaults
|
|
84
|
+
blacklisted_subscribers.each do |subscriber|
|
|
85
|
+
subscriber.patterns.each do |pattern|
|
|
86
|
+
unsubscribe_listeners(subscriber, pattern)
|
|
87
|
+
end
|
|
66
88
|
end
|
|
89
|
+
|
|
90
|
+
# Rails 7.1 adds ActionView::LogSubscriber::Start which subscribes
|
|
91
|
+
# separately and logs "Rendering..." messages at the start of rendering
|
|
92
|
+
# see https://github.com/rails/rails/commit/9c58a54702b038b9acebdb3efa85c26156ff1987#diff-fd389a9f74e2259b56015e3f8d15a5ce33c093045dd4cb354e82d6d81fe9b06aR98-R99
|
|
93
|
+
unsubscribe_action_view_start_listeners
|
|
67
94
|
end
|
|
68
|
-
end
|
|
69
95
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
96
|
+
def unsubscribe_listeners(subscriber, pattern)
|
|
97
|
+
notifier = ActiveSupport::Notifications.notifier
|
|
98
|
+
notifier.listeners_for(Array.wrap(pattern).first).each do |listener|
|
|
99
|
+
if listener.delegates_to?(subscriber)
|
|
100
|
+
ActiveSupport::Notifications.unsubscribe(listener)
|
|
101
|
+
end
|
|
75
102
|
end
|
|
76
103
|
end
|
|
77
|
-
end
|
|
78
104
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
105
|
+
def unsubscribe_action_view_start_listeners
|
|
106
|
+
return unless defined?(ActionView::LogSubscriber::Start)
|
|
107
|
+
|
|
108
|
+
notifier = ActiveSupport::Notifications.notifier
|
|
109
|
+
%w[render_template.action_view render_layout.action_view].each do |pattern|
|
|
110
|
+
notifier.listeners_for(pattern).each do |listener|
|
|
111
|
+
if listener.delegate.is_a?(ActionView::LogSubscriber::Start)
|
|
112
|
+
ActiveSupport::Notifications.unsubscribe(listener)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def blacklisted_subscribers
|
|
119
|
+
ActiveSupport::LogSubscriber.log_subscribers.select do |subscriber|
|
|
120
|
+
SUBSCRIBER_BLACKLIST.include?(subscriber.class)
|
|
121
|
+
end
|
|
82
122
|
end
|
|
83
123
|
end
|
|
84
124
|
end
|
data/lib/epilog/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: epilog
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Justin Howard
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-02-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: combustion
|
|
@@ -31,9 +31,6 @@ dependencies:
|
|
|
31
31
|
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
33
|
version: '4.2'
|
|
34
|
-
- - "<"
|
|
35
|
-
- !ruby/object:Gem::Version
|
|
36
|
-
version: '7'
|
|
37
34
|
type: :development
|
|
38
35
|
prerelease: false
|
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -41,9 +38,6 @@ dependencies:
|
|
|
41
38
|
- - ">="
|
|
42
39
|
- !ruby/object:Gem::Version
|
|
43
40
|
version: '4.2'
|
|
44
|
-
- - "<"
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: '7'
|
|
47
41
|
- !ruby/object:Gem::Dependency
|
|
48
42
|
name: rspec
|
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -62,31 +56,31 @@ dependencies:
|
|
|
62
56
|
name: rspec-rails
|
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
|
64
58
|
requirements:
|
|
65
|
-
- - "
|
|
59
|
+
- - ">="
|
|
66
60
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: '
|
|
61
|
+
version: '7.0'
|
|
68
62
|
type: :development
|
|
69
63
|
prerelease: false
|
|
70
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
71
65
|
requirements:
|
|
72
|
-
- - "
|
|
66
|
+
- - ">="
|
|
73
67
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: '
|
|
68
|
+
version: '7.0'
|
|
75
69
|
- !ruby/object:Gem::Dependency
|
|
76
70
|
name: sqlite3
|
|
77
71
|
requirement: !ruby/object:Gem::Requirement
|
|
78
72
|
requirements:
|
|
79
|
-
- - "
|
|
73
|
+
- - ">="
|
|
80
74
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '1.
|
|
75
|
+
version: '1.4'
|
|
82
76
|
type: :development
|
|
83
77
|
prerelease: false
|
|
84
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
79
|
requirements:
|
|
86
|
-
- - "
|
|
80
|
+
- - ">="
|
|
87
81
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: '1.
|
|
89
|
-
description:
|
|
82
|
+
version: '1.4'
|
|
83
|
+
description:
|
|
90
84
|
email:
|
|
91
85
|
- jmhoward0@gmail.com
|
|
92
86
|
executables: []
|
|
@@ -126,9 +120,9 @@ licenses:
|
|
|
126
120
|
- MIT
|
|
127
121
|
metadata:
|
|
128
122
|
changelog_uri: https://github.com/nullscreen/epilog/blob/main/CHANGELOG.md
|
|
129
|
-
documentation_uri: https://www.rubydoc.info/gems/epilog/0.
|
|
123
|
+
documentation_uri: https://www.rubydoc.info/gems/epilog/0.9.2
|
|
130
124
|
rubygems_mfa_required: 'true'
|
|
131
|
-
post_install_message:
|
|
125
|
+
post_install_message:
|
|
132
126
|
rdoc_options: []
|
|
133
127
|
require_paths:
|
|
134
128
|
- lib
|
|
@@ -136,15 +130,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
136
130
|
requirements:
|
|
137
131
|
- - ">="
|
|
138
132
|
- !ruby/object:Gem::Version
|
|
139
|
-
version: '
|
|
133
|
+
version: '3.3'
|
|
140
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
135
|
requirements:
|
|
142
136
|
- - ">="
|
|
143
137
|
- !ruby/object:Gem::Version
|
|
144
138
|
version: '0'
|
|
145
139
|
requirements: []
|
|
146
|
-
rubygems_version: 3.
|
|
147
|
-
signing_key:
|
|
140
|
+
rubygems_version: 3.4.20
|
|
141
|
+
signing_key:
|
|
148
142
|
specification_version: 4
|
|
149
143
|
summary: A JSON logger with Rails support
|
|
150
144
|
test_files: []
|