epilog 0.4.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c182e5b6fad45d60dcbf0e37843e075e6775d76e3888a632056cef356235768
4
- data.tar.gz: bb7095818994ab3532c70c691180fe1018089e587cc7819faf1441bb6532acf9
3
+ metadata.gz: 489f54c6b2527b191f528402ea23ee3188d98705dc9c06f995176c38110e3ff9
4
+ data.tar.gz: 65ec51b26a5b23cde1fd997d02d743d78ffb193df568f770b513e9b6d9010320
5
5
  SHA512:
6
- metadata.gz: 07552c37f2ebcc5febb7d94f227801c8f89e15eae7904e493c6575bd83819a1989b7229a9d1559ffc9f4651884611160b77779cfce11fa1abcf48c71bd484612
7
- data.tar.gz: 5664a1841cdd95b1af21e8796a374f30d5ddfd26faf6ef4782abc9de435098d351f3e29d2b778358e74c1af5ae55b9cb4d4155c0cba776201ed9d350286abc41
6
+ metadata.gz: fc8a27b6da915720290f5e23acf02f7fc3e0afeb79608365bb09fb7d799c9d0663f5f9010472b5beb962bbe6cdbd3653239effbc390b97cd9c1ea56c2da8c8cd
7
+ data.tar.gz: f2b9f9ffcfaf8fdf021bdea32ee086ae440d919501bc6a342f1dd854b9507590b0b40b70b40118918307805c8a519ed7fc70e03b6b18d0b257573126afe0224d
data/CHANGLOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0
4
+
5
+ - Add options to enable/disable start and end logs [#15](https://github.com/machinima/epilog/pull/15)
6
+ - Fix with_context to use ensure [#16](https://github.com/machinima/epilog/pull/16)
7
+
3
8
  ## 0.4.0
4
9
 
5
10
  - Add context support to Logger [#12](https://github.com/machinima/epilog/pull/12)
@@ -5,6 +5,7 @@ module Epilog
5
5
  def with_context(context)
6
6
  push_context(context)
7
7
  yield
8
+ ensure
8
9
  pop_context
9
10
  end
10
11
 
@@ -12,25 +12,11 @@ module Epilog
12
12
  .merge(event.payload[:context])
13
13
  )
14
14
 
15
- info do
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
- info do
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)
@@ -13,6 +13,8 @@ module Epilog
13
13
 
14
14
  def perform_start(event)
15
15
  push_context(job: short_job_hash(event.payload[:job]))
16
+ return unless config.double_job_logs
17
+
16
18
  info { event_hash('Performing job', event) }
17
19
  end
18
20
 
@@ -17,6 +17,10 @@ module Epilog
17
17
  def pop_context
18
18
  @logger.try(:pop_context)
19
19
  end
20
+
21
+ def config
22
+ ::Rails.application.config.epilog
23
+ end
20
24
  end
21
25
  end
22
26
  end
@@ -20,6 +20,8 @@ module Epilog
20
20
  ].freeze
21
21
 
22
22
  config.epilog = ActiveSupport::OrderedOptions.new
23
+ config.epilog.double_request_logs = true
24
+ config.epilog.double_job_logs = true
23
25
  config.epilog.subscriptions = %i[
24
26
  action_controller
25
27
  action_mailer
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Epilog
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
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.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Howard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-10 00:00:00.000000000 Z
11
+ date: 2019-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler