logjoy 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/logjoy/log_subscribers/action_controller.rb +6 -0
- data/lib/logjoy/railtie.rb +4 -0
- data/lib/logjoy/version.rb +1 -1
- data/lib/logjoy.rb +8 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18d7116caaea6d515e1379e012a599cdfc5be1fc380ed049fbe9af0942156aba
|
4
|
+
data.tar.gz: 68937fd8fcd5e02c5b151dd79693e7fc9282623516b15ce18c8c5eece09134a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
data/lib/logjoy/railtie.rb
CHANGED
@@ -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)
|
data/lib/logjoy/version.rb
CHANGED
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
|
|