epilog 0.4.0 → 0.7.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/.gitignore +1 -0
- data/.travis.yml +4 -2
- data/{CHANGLOG.md → CHANGELOG.md} +13 -0
- data/Gemfile +5 -0
- data/epilog.gemspec +3 -3
- data/lib/epilog/context_logging.rb +1 -0
- data/lib/epilog/rails/action_controller_subscriber.rb +29 -16
- data/lib/epilog/rails/action_mailer_subscriber.rb +2 -0
- data/lib/epilog/rails/active_job_subscriber.rb +55 -7
- data/lib/epilog/rails/epilog_ext.rb +7 -2
- data/lib/epilog/rails/ext/action_controller.rb +14 -1
- data/lib/epilog/rails/log_subscriber.rb +4 -0
- data/lib/epilog/rails/railtie.rb +17 -2
- data/lib/epilog/version.rb +1 -1
- metadata +14 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 32a54d6c7ea304907eb4dc22c25c9929b3da12567229bff59011e71d9beb6657
|
|
4
|
+
data.tar.gz: 6368c2823685e10c8f599e0b2a38fbe51d815276427d7678de23438cb91967f2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9c7043de6697ddd6ec8c5b9bd5e9c4b4f6514ac294832778df3001cee5b33095d9da4ba98c94a4d9719a543774211bd0451c9648274833b78c17acab1d06778c
|
|
7
|
+
data.tar.gz: b0c7afa816aafe154ac47d944baa5398c692d2c5b33f4c014460486daae83f280c070d63f8a09b67b2025f4bf9e153878b84aad848b6ce1780699e9ed75ae00d
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
|
@@ -4,10 +4,12 @@ rvm:
|
|
|
4
4
|
- 2.3
|
|
5
5
|
- 2.4
|
|
6
6
|
- 2.5
|
|
7
|
+
- 2.6
|
|
7
8
|
env:
|
|
8
9
|
matrix:
|
|
9
|
-
- RAILS_VERSION=4.2
|
|
10
10
|
- RAILS_VERSION=5.2
|
|
11
|
+
- RAILS_VERSION=6.0
|
|
12
|
+
- RAILS_VERSION=6.1
|
|
11
13
|
global:
|
|
12
14
|
- COVERAGE=1
|
|
13
15
|
- secure: 'nm0AJBULqunzS//h26lblqWHV4Kl0Ij9OPVHMI761TNeFFjP2+KKUVh4qYEKrdUDp7pk9Wa4CdAB9EFLYTJMwyK8RlSkdMLaHGT9xdOqbycBS6vkW2symvdu58SSdsNmnnFV4ebOwEmEcDhAh8SyT0ZkUVhyzGntdzOOZmULi57kOwm8QGrrr4/4xaTmDleZlTDS404nD28wJctaBT8Xa33inaYYrHLKz4xbvFFtptrPb+Arav9enljqiqOu4XjXCIP2eOSP7PHkDPuRn0JKDFT3zKmj0MIUbYkoheQL6R3tMF9zx5gm4GKbd7iunuIsjbFweiveZwZhfNGDPCICuw76UWZCrN4PpomA7XDNjbs0JVRJvnBxLZk5X3w3Sacb4zBTd+U8WH7uAb9qdD7m4xUswox4tPZDPXYObw2PDqtLlsSRn3WDKsnG0/Tt0D+kFsx43MbrvspdOzjarJsIXzU9aJqfE97nM4ZrNcktsW4PrqGflhcDVTKg+kLQj4bO0csR1W/JhGHN0JsVNUmNFN9QqpuRxxI/AmnPBtKR29DDy3BUv1b/kCZbsqq4+wbgCKDJng5VBgpG4VekOiTT2xmlwoxNK4IUAISbu7G/eyCcp33jb+27QE74a13xQsMLvh/wjh1sFEfzJvQzXFL+gjkVP4Z/+uSbc2+8/p+FKm8='
|
|
@@ -28,7 +30,7 @@ after_script:
|
|
|
28
30
|
jobs:
|
|
29
31
|
include:
|
|
30
32
|
- stage: release
|
|
31
|
-
rvm: 2.
|
|
33
|
+
rvm: 2.6
|
|
32
34
|
script: skip
|
|
33
35
|
deploy:
|
|
34
36
|
provider: rubygems
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
- Add support for Rails 6 [#18](https://github.com/machinima/epilog/pull/18)
|
|
6
|
+
|
|
7
|
+
## 0.6.0
|
|
8
|
+
|
|
9
|
+
- Add support for Rails 5 API-only controllers [#17](https://github.com/machinima/epilog/pull/17)
|
|
10
|
+
|
|
11
|
+
## 0.5.0
|
|
12
|
+
|
|
13
|
+
- Add options to enable/disable start and end logs [#15](https://github.com/machinima/epilog/pull/15)
|
|
14
|
+
- Fix with_context to use ensure [#16](https://github.com/machinima/epilog/pull/16)
|
|
15
|
+
|
|
3
16
|
## 0.4.0
|
|
4
17
|
|
|
5
18
|
- Add context support to Logger [#12](https://github.com/machinima/epilog/pull/12)
|
data/Gemfile
CHANGED
data/epilog.gemspec
CHANGED
|
@@ -21,15 +21,15 @@ Gem::Specification.new do |spec|
|
|
|
21
21
|
|
|
22
22
|
spec.add_development_dependency 'bundler', '>= 1.12'
|
|
23
23
|
spec.add_development_dependency 'byebug', '~> 11.0'
|
|
24
|
-
spec.add_development_dependency 'combustion', '~> 1.
|
|
24
|
+
spec.add_development_dependency 'combustion', '~> 1.3'
|
|
25
25
|
spec.add_development_dependency 'irb'
|
|
26
|
-
spec.add_development_dependency 'rails', '>= 4.2', '<
|
|
26
|
+
spec.add_development_dependency 'rails', '>= 4.2', '< 7'
|
|
27
27
|
spec.add_development_dependency 'rake', '~> 13.0'
|
|
28
28
|
spec.add_development_dependency 'redcarpet', '~> 3.5'
|
|
29
29
|
spec.add_development_dependency 'rspec', '~> 3.4'
|
|
30
30
|
spec.add_development_dependency 'rspec-rails', '~> 3.8.1'
|
|
31
31
|
spec.add_development_dependency 'rubocop', '0.75'
|
|
32
32
|
spec.add_development_dependency 'simplecov', '~> 0.17'
|
|
33
|
-
spec.add_development_dependency 'sqlite3', '~> 1.3', '< 1.
|
|
33
|
+
spec.add_development_dependency 'sqlite3', '~> 1.3', '< 1.5'
|
|
34
34
|
spec.add_development_dependency 'yard', '~> 0.9.11'
|
|
35
35
|
end
|
|
@@ -12,25 +12,11 @@ module Epilog
|
|
|
12
12
|
.merge(event.payload[:context])
|
|
13
13
|
)
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
{
|
|
17
|
-
message: "#{request_string(event)} started",
|
|
18
|
-
request: request_hash(event)
|
|
19
|
-
}
|
|
20
|
-
end
|
|
15
|
+
log_start(event) if config.double_request_logs
|
|
21
16
|
end
|
|
22
17
|
|
|
23
18
|
def process_request(event)
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
message: response_string(event),
|
|
27
|
-
request: short_request_hash(event),
|
|
28
|
-
response: response_hash(event),
|
|
29
|
-
metrics: process_metrics(event.payload[:metrics]
|
|
30
|
-
.merge(request_runtime: event.duration.round(2)))
|
|
31
|
-
}
|
|
32
|
-
end
|
|
33
|
-
|
|
19
|
+
log_end(event)
|
|
34
20
|
pop_context
|
|
35
21
|
end
|
|
36
22
|
|
|
@@ -84,6 +70,33 @@ module Epilog
|
|
|
84
70
|
|
|
85
71
|
private
|
|
86
72
|
|
|
73
|
+
def log_start(event)
|
|
74
|
+
info do
|
|
75
|
+
{
|
|
76
|
+
message: "#{request_string(event)} started",
|
|
77
|
+
request: request_hash(event)
|
|
78
|
+
}
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def log_end(event) # rubocop:disable MethodLength
|
|
83
|
+
request = if config.double_request_logs
|
|
84
|
+
short_request_hash(event)
|
|
85
|
+
else
|
|
86
|
+
request_hash(event)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
info do
|
|
90
|
+
{
|
|
91
|
+
message: response_string(event),
|
|
92
|
+
request: request,
|
|
93
|
+
response: response_hash(event),
|
|
94
|
+
metrics: process_metrics(event.payload[:metrics]
|
|
95
|
+
.merge(request_runtime: event.duration.round(2)))
|
|
96
|
+
}
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
87
100
|
def request_hash(event) # rubocop:disable AbcSize, MethodLength
|
|
88
101
|
request = event.payload[:request]
|
|
89
102
|
param_filter = request.send(:parameter_filter)
|
|
@@ -3,9 +3,27 @@
|
|
|
3
3
|
module Epilog
|
|
4
4
|
module Rails
|
|
5
5
|
class ActiveJobSubscriber < LogSubscriber
|
|
6
|
+
# rubocop:disable Metrics/MethodLength
|
|
6
7
|
def enqueue(event)
|
|
7
|
-
|
|
8
|
+
ex = event.payload[:exception_object]
|
|
9
|
+
|
|
10
|
+
if ex
|
|
11
|
+
error do
|
|
12
|
+
event_hash('Failed enqueuing job', event)
|
|
13
|
+
end
|
|
14
|
+
elsif event.payload[:aborted]
|
|
15
|
+
info do
|
|
16
|
+
event_hash(
|
|
17
|
+
'Failed enqueuing job, a before_enqueue callback' \
|
|
18
|
+
' halted the enqueuing execution.',
|
|
19
|
+
event
|
|
20
|
+
)
|
|
21
|
+
end
|
|
22
|
+
else
|
|
23
|
+
info { event_hash('Enqueued job', event) }
|
|
24
|
+
end
|
|
8
25
|
end
|
|
26
|
+
# rubocop:enable Metrics/MethodLength
|
|
9
27
|
|
|
10
28
|
def enqueue_at(event)
|
|
11
29
|
enqueue(event)
|
|
@@ -13,19 +31,49 @@ module Epilog
|
|
|
13
31
|
|
|
14
32
|
def perform_start(event)
|
|
15
33
|
push_context(job: short_job_hash(event.payload[:job]))
|
|
34
|
+
return unless config.double_job_logs
|
|
35
|
+
|
|
16
36
|
info { event_hash('Performing job', event) }
|
|
17
37
|
end
|
|
18
38
|
|
|
39
|
+
# rubocop:disable Metrics/MethodLength
|
|
40
|
+
# rubocop:disable Metrics/AbcSize
|
|
19
41
|
def perform(event)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
42
|
+
ex = event.payload[:exception_object]
|
|
43
|
+
if ex
|
|
44
|
+
error do
|
|
45
|
+
event_hash('Error performing job', event).merge(
|
|
46
|
+
metrics: {
|
|
47
|
+
job_runtime: event.duration
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
end
|
|
51
|
+
elsif event.payload[:aborted]
|
|
52
|
+
error do
|
|
53
|
+
event_hash(
|
|
54
|
+
'Error performing job, a before_perform ' \
|
|
55
|
+
'callback halted the job execution',
|
|
56
|
+
event
|
|
57
|
+
).merge(
|
|
58
|
+
metrics: {
|
|
59
|
+
job_runtime: event.duration
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
end
|
|
63
|
+
else
|
|
64
|
+
info do
|
|
65
|
+
event_hash('Performed job', event).merge(
|
|
66
|
+
metrics: {
|
|
67
|
+
job_runtime: event.duration
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
end
|
|
26
71
|
end
|
|
72
|
+
|
|
27
73
|
pop_context
|
|
28
74
|
end
|
|
75
|
+
# rubocop:enable Metrics/MethodLength
|
|
76
|
+
# rubocop:enable Metrics/AbcSize
|
|
29
77
|
|
|
30
78
|
private
|
|
31
79
|
|
|
@@ -2,10 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
module Epilog
|
|
4
4
|
class Logger
|
|
5
|
-
include LoggerSilence
|
|
6
|
-
|
|
7
5
|
def silencer
|
|
8
6
|
false
|
|
9
7
|
end
|
|
10
8
|
end
|
|
11
9
|
end
|
|
10
|
+
|
|
11
|
+
logger_silencer = if Rails::VERSION::MAJOR >= 6
|
|
12
|
+
ActiveSupport::LoggerSilence
|
|
13
|
+
else
|
|
14
|
+
::LoggerSilence
|
|
15
|
+
end
|
|
16
|
+
Epilog::Logger.send(:include, logger_silencer)
|
|
@@ -47,4 +47,17 @@ module Epilog
|
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
def prepend_controller_ext
|
|
51
|
+
ActionController::Base.prepend(Epilog::ActionControllerExt)
|
|
52
|
+
return unless defined? ActionController::API
|
|
53
|
+
|
|
54
|
+
ActionController::API.prepend(Epilog::ActionControllerExt)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
if ::Rails::VERSION::MAJOR < 5
|
|
58
|
+
prepend_controller_ext
|
|
59
|
+
else
|
|
60
|
+
ActiveSupport.on_load(:action_controller_base) do
|
|
61
|
+
prepend_controller_ext
|
|
62
|
+
end
|
|
63
|
+
end
|
data/lib/epilog/rails/railtie.rb
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
module Epilog
|
|
4
4
|
module Rails
|
|
5
5
|
class Railtie < ::Rails::Railtie
|
|
6
|
+
def self.rails_6_1_higher?
|
|
7
|
+
Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new('6.1.0')
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# We need this in Rails 6.
|
|
11
|
+
# Without this line `ActiveJob::LogSubscriber` fails
|
|
12
|
+
# with unknown contant error
|
|
13
|
+
ActiveSupport.run_load_hooks(:active_job, ActiveJob::Base)
|
|
14
|
+
|
|
6
15
|
SUBSCRIBERS = {
|
|
7
16
|
action_controller: ActionControllerSubscriber,
|
|
8
17
|
action_mailer: ActionMailerSubscriber,
|
|
@@ -16,10 +25,16 @@ module Epilog
|
|
|
16
25
|
ActionMailer::LogSubscriber,
|
|
17
26
|
ActionView::LogSubscriber,
|
|
18
27
|
ActiveRecord::LogSubscriber,
|
|
19
|
-
|
|
28
|
+
if rails_6_1_higher?
|
|
29
|
+
ActiveJob::LogSubscriber
|
|
30
|
+
else
|
|
31
|
+
ActiveJob::Logging::LogSubscriber
|
|
32
|
+
end
|
|
20
33
|
].freeze
|
|
21
34
|
|
|
22
35
|
config.epilog = ActiveSupport::OrderedOptions.new
|
|
36
|
+
config.epilog.double_request_logs = true
|
|
37
|
+
config.epilog.double_job_logs = true
|
|
23
38
|
config.epilog.subscriptions = %i[
|
|
24
39
|
action_controller
|
|
25
40
|
action_mailer
|
|
@@ -54,7 +69,7 @@ module Epilog
|
|
|
54
69
|
|
|
55
70
|
def unsubscribe_listeners(subscriber, pattern)
|
|
56
71
|
notifier = ActiveSupport::Notifications.notifier
|
|
57
|
-
notifier.listeners_for(pattern).each do |listener|
|
|
72
|
+
notifier.listeners_for(Array.wrap(pattern).first).each do |listener|
|
|
58
73
|
if listener.delegates_to?(subscriber)
|
|
59
74
|
ActiveSupport::Notifications.unsubscribe(listener)
|
|
60
75
|
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.7.0
|
|
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: 2022-07-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -44,14 +44,14 @@ dependencies:
|
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 1.
|
|
47
|
+
version: '1.3'
|
|
48
48
|
type: :development
|
|
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: 1.
|
|
54
|
+
version: '1.3'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: irb
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -75,7 +75,7 @@ dependencies:
|
|
|
75
75
|
version: '4.2'
|
|
76
76
|
- - "<"
|
|
77
77
|
- !ruby/object:Gem::Version
|
|
78
|
-
version: '
|
|
78
|
+
version: '7'
|
|
79
79
|
type: :development
|
|
80
80
|
prerelease: false
|
|
81
81
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -85,7 +85,7 @@ dependencies:
|
|
|
85
85
|
version: '4.2'
|
|
86
86
|
- - "<"
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: '
|
|
88
|
+
version: '7'
|
|
89
89
|
- !ruby/object:Gem::Dependency
|
|
90
90
|
name: rake
|
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -179,7 +179,7 @@ dependencies:
|
|
|
179
179
|
version: '1.3'
|
|
180
180
|
- - "<"
|
|
181
181
|
- !ruby/object:Gem::Version
|
|
182
|
-
version: '1.
|
|
182
|
+
version: '1.5'
|
|
183
183
|
type: :development
|
|
184
184
|
prerelease: false
|
|
185
185
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -189,7 +189,7 @@ dependencies:
|
|
|
189
189
|
version: '1.3'
|
|
190
190
|
- - "<"
|
|
191
191
|
- !ruby/object:Gem::Version
|
|
192
|
-
version: '1.
|
|
192
|
+
version: '1.5'
|
|
193
193
|
- !ruby/object:Gem::Dependency
|
|
194
194
|
name: yard
|
|
195
195
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -204,7 +204,7 @@ dependencies:
|
|
|
204
204
|
- - "~>"
|
|
205
205
|
- !ruby/object:Gem::Version
|
|
206
206
|
version: 0.9.11
|
|
207
|
-
description:
|
|
207
|
+
description:
|
|
208
208
|
email:
|
|
209
209
|
- jmhoward0@gmail.com
|
|
210
210
|
executables: []
|
|
@@ -216,7 +216,7 @@ files:
|
|
|
216
216
|
- ".rubocop.yml"
|
|
217
217
|
- ".travis.yml"
|
|
218
218
|
- ".yardopts"
|
|
219
|
-
-
|
|
219
|
+
- CHANGELOG.md
|
|
220
220
|
- Gemfile
|
|
221
221
|
- LICENSE.txt
|
|
222
222
|
- README.md
|
|
@@ -258,7 +258,7 @@ homepage: https://github.com/machinima/epilog
|
|
|
258
258
|
licenses:
|
|
259
259
|
- Apache-2.0
|
|
260
260
|
metadata: {}
|
|
261
|
-
post_install_message:
|
|
261
|
+
post_install_message:
|
|
262
262
|
rdoc_options: []
|
|
263
263
|
require_paths:
|
|
264
264
|
- lib
|
|
@@ -273,9 +273,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
273
273
|
- !ruby/object:Gem::Version
|
|
274
274
|
version: '0'
|
|
275
275
|
requirements: []
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
signing_key:
|
|
276
|
+
rubygems_version: 3.3.7
|
|
277
|
+
signing_key:
|
|
279
278
|
specification_version: 4
|
|
280
279
|
summary: A JSON logger with Rails support
|
|
281
280
|
test_files: []
|