rorvswild 1.5.3 → 1.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f458deb05f3508f795dc06993742ee466d8615e86886f5997bf0d1743d3adb0
4
- data.tar.gz: ea17ef8609b1587c259a074a08f3b3657960b2fe8e76ac533ed3778464f820f5
3
+ metadata.gz: 823ab7934d6f40bcf1e9cea8b11b67709fdf3291ee7f751c214bc326f27ffb57
4
+ data.tar.gz: d886b176eeb69afc9c02e927cf783319d310e9854160aac9769ec0fb8fe4b0b3
5
5
  SHA512:
6
- metadata.gz: f7402dd0a270265faf614b4ea6919b1b9469b164a8b844b2814a73426a663ce83b144fc3208b2eae2dee3377a1d0f88ffe1e716e60fc3876e7a07ea9aad92127
7
- data.tar.gz: 71cbe80cc68b6730ba128c44a96767d94e8b56e5ae02328b5cb4667443ad0b316280562e8eca567039d413db841fe5583e0dd8626e993dd7c7fe5715371c8b36
6
+ metadata.gz: afc6de959ccc4f34dad4fd318c55a2bb55d844b66dfed98acada8c729f84cdad334f28394178ed90cc11582b95da94b35b101467bc0e6cda806cf14482814635
7
+ data.tar.gz: c2a28c624fd45b76adc2b3718dc3994db0418166de4b3b40d51d5eb11f72f4a9405d9a752c6dac1f98a632cda0f632117387dea08fa4982aa524cbc38b1b91b0
data/README.md CHANGED
@@ -167,6 +167,32 @@ Finally here is the list of all plugins you can ignore :
167
167
  - Resque
168
168
  - Sidekiq
169
169
 
170
+ #### Change logger
171
+
172
+ By default RorVsWild uses `Rails.logger` or standard output. However in some cases you want to isolate RorVsWild's logs.
173
+ To do that, you have to specifiy the log destination via the `logger` option :
174
+
175
+ ```yaml
176
+ # config/rorvswild.yml
177
+ production:
178
+ api_key: API_KEY
179
+ logger: log/rorvswild.yml
180
+ ```
181
+
182
+ Here is the equivalent if you prefer initialising RorVsWild manually :
183
+
184
+ ```ruby
185
+ # config/initializers/rorvswild.rb
186
+ RorVsWild.start(api_key: "API_KEY", logger: "log/rorvswild.log")
187
+ ```
188
+
189
+ In the case you want a custom logger such as Syslog, you can only do it by initialising it manually :
190
+
191
+ ```ruby
192
+ # config/initializers/rorvswild.rb
193
+ RorVsWild.start(api_key: "API_KEY", logger: Logger::Syslog.new)
194
+ ```
195
+
170
196
  ## Contributing
171
197
 
172
198
  1. Fork it ( https://github.com/[my-github-username]/rorvswild/fork )
@@ -38,6 +38,7 @@ production:
38
38
  # - Redis
39
39
  # - Resque
40
40
  # - Sidekiq
41
+ # logger: log/rorvswild.log # By default it uses Rails.logger or Logger.new(STDOUT)
41
42
  YAML
42
43
  end
43
44
  end
@@ -4,29 +4,28 @@ module RorVsWild
4
4
  def self.setup
5
5
  return if @installed
6
6
  return unless defined?(::ActionController::Base)
7
- ActiveSupport::Notifications.subscribe("process_action.action_controller", new)
7
+ ::ActionController::Base.around_action(&method(:around_action))
8
8
  ::ActionController::Base.rescue_from(StandardError) { |ex| RorVsWild::Plugin::ActionController.after_exception(ex, self) }
9
9
  @installed = true
10
10
  end
11
11
 
12
- def start(name, id, payload)
13
- controller_action = "#{payload[:controller]}##{payload[:action]}"
14
- if !RorVsWild.agent.ignored_request?(controller_action)
15
- section = RorVsWild::Section.start
16
- RorVsWild.agent.current_data[:name] = controller_action
17
- controller = payload[:headers]["action_controller.instance".freeze]
18
- method_name = controller.method_for_action(payload[:action])
19
- section.file, section.line = controller.method(method_name).source_location
20
- section.file = RorVsWild.agent.locator.relative_path(section.file)
21
- section.command = "#{controller.class}##{method_name}"
22
- section.kind = "code".freeze
12
+ def self.around_action(controller, block)
13
+ controller_action = "#{controller.class}##{controller.action_name}"
14
+ return block.call if RorVsWild.agent.ignored_request?(controller_action)
15
+ begin
16
+ RorVsWild::Section.start do |section|
17
+ method_name = controller.method_for_action(controller.action_name)
18
+ section.file, section.line = controller.method(method_name).source_location
19
+ section.file = RorVsWild.agent.locator.relative_path(section.file)
20
+ section.command = "#{controller.class}##{method_name}"
21
+ RorVsWild.agent.current_data[:name] = controller_action
22
+ end
23
+ block.call
24
+ ensure
25
+ RorVsWild::Section.stop
23
26
  end
24
27
  end
25
28
 
26
- def finish(name, id, payload)
27
- RorVsWild::Section.stop
28
- end
29
-
30
29
  def self.after_exception(exception, controller)
31
30
  if hash = RorVsWild.agent.push_exception(exception)
32
31
  hash[:session] = controller.session.to_hash
@@ -1,3 +1,3 @@
1
1
  module RorVsWild
2
- VERSION = "1.5.3".freeze
2
+ VERSION = "1.5.4".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rorvswild
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis Bernard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-06 00:00:00.000000000 Z
11
+ date: 2020-05-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Performances and quality insights for rails developers.
14
14
  email: