logjoy 0.2.0 → 0.3.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: ef1c163f606f4ff39547e838da0dead49bf4b3ec13824e17f97ab5bc43398e51
4
- data.tar.gz: d3344d8049afb40f20786739a945ac1706ad47f41bed08f6939d5a827d6ffb5c
3
+ metadata.gz: 18d7116caaea6d515e1379e012a599cdfc5be1fc380ed049fbe9af0942156aba
4
+ data.tar.gz: 68937fd8fcd5e02c5b151dd79693e7fc9282623516b15ce18c8c5eece09134a2
5
5
  SHA512:
6
- metadata.gz: 1a1b5d286379fbdaa60f2dd0b81d6a8258ccff40706ce37dfdd9e16c9b135a31ef6e6048e1cc6ff9d22bc6fe9298ce1ee2f6ef6a6bd1a411af7e9349524d0344
7
- data.tar.gz: a7cf2a4837f14532ce79591b271eab83a3074e818657e44fc564221f74741d210fee001dd5464f27bfb0508c589bf5d2b1dbaa5cf74cc3cc8f42045cb9cb8f05
6
+ metadata.gz: c90722446495e9e127bed6a0d90b0dd40f51842e7eaa403645ceda2acc30c31d9c338a088a8a0842345ce7e97c6d73ae7432f741db711694521c692dbc0c17d6
7
+ data.tar.gz: 9b4a01ccb3f7c7391eb43ecfff6ee79cd8f63f7e2b8bd62550df474bef719f2eb0ce879565224dfc6c51dcffc5b0d10274362ee00d4e60e7eccdea5971f34b8f
data/README.md CHANGED
@@ -53,6 +53,8 @@ Rails.application.configure do |config|
53
53
  config.logjoy.customizer = CustomizerClass
54
54
  # or
55
55
  config.logjoy.customizer = ->(event) { ... }
56
+
57
+ config.logjoy.filters = ['/health_check']
56
58
  end
57
59
  ```
58
60
 
@@ -64,6 +66,9 @@ It should return a hash that will be added to the log in a `:custom` field.
64
66
  More documentation about this event can be found here:
65
67
  https://guides.rubyonrails.org/active_support_instrumentation.html#process-action-action-controller
66
68
 
69
+ The filters configuration can be used to ignore requests with the given path to
70
+ reduce log noise from things like health checks.
71
+
67
72
  ## Development
68
73
 
69
74
  After checking out the repo, run `bin/setup` to install dependencies. Then, run
@@ -8,6 +8,8 @@ module Logjoy
8
8
  module LogSubscribers
9
9
  class ActionController < ActiveSupport::LogSubscriber
10
10
  def process_action(event)
11
+ return if ignore_event?(event)
12
+
11
13
  info do
12
14
  payload = event.payload
13
15
 
@@ -35,6 +37,10 @@ module Logjoy
35
37
 
36
38
  private
37
39
 
40
+ def ignore_event?(event)
41
+ Logjoy.filters.include?(event.payload[:path])
42
+ end
43
+
38
44
  def rounded_ms(value)
39
45
  return 'N/A' if value.nil?
40
46
 
@@ -11,6 +11,10 @@ module Logjoy
11
11
  Logjoy.set_customizer(app)
12
12
  end
13
13
 
14
+ config.after_initialize do |app|
15
+ Logjoy.set_path_filters(app)
16
+ end
17
+
14
18
  Logjoy::REPLACE_SUBSCRIBERS.each do |component|
15
19
  config.after_initialize do |app|
16
20
  Logjoy.detach_default_subscriber(app, component)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Logjoy
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
data/lib/logjoy.rb CHANGED
@@ -12,7 +12,8 @@ module Logjoy
12
12
  class Error < StandardError; end
13
13
  module_function
14
14
 
15
- mattr_accessor :customizer
15
+ mattr_accessor :customizer, :filters
16
+ self.filters = []
16
17
 
17
18
  def custom_fields(event)
18
19
  return {} if customizer.nil?
@@ -26,6 +27,12 @@ module Logjoy
26
27
  self.customizer = app.config.logjoy.customizer
27
28
  end
28
29
 
30
+ def set_path_filters(app)
31
+ return unless enabled?(app)
32
+
33
+ self.filters = app.config.logjoy.filters || []
34
+ end
35
+
29
36
  REPLACE_SUBSCRIBERS = %i[action_controller].freeze
30
37
  DETACH_SUBSCRIBERS = %i[action_view action_mailer active_storage].freeze
31
38
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logjoy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat McGee