time_bandits 0.1.0 → 0.1.1

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.
@@ -7,7 +7,6 @@ module ActionController #:nodoc:
7
7
 
8
8
  # patch to ensure that the completed line is always written to the log
9
9
  def process_action(action, *args)
10
- TimeBandits.reset
11
10
 
12
11
  raw_payload = {
13
12
  :controller => self.class.name,
@@ -72,7 +71,8 @@ module ActionController #:nodoc:
72
71
  def process_action(event)
73
72
  payload = event.payload
74
73
  additions = ActionController::Base.log_process_action(payload)
75
- Thread.current[:time_bandits_completed_info] = [event.duration, additions]
74
+ Thread.current[:time_bandits_completed_info] =
75
+ [ event.duration, additions, payload[:view_runtime], "#{payload[:controller]}##{payload[:action]}" ]
76
76
  end
77
77
  end
78
78
 
@@ -1,8 +1,9 @@
1
- require 'rails/rack/logger'
2
-
3
- module Rails
1
+ module TimeBandits
4
2
  module Rack
5
- class Logger
3
+ class Logger < ActiveSupport::LogSubscriber
4
+ def initialize(app)
5
+ @app = app
6
+ end
6
7
 
7
8
  def call(env)
8
9
  start_time = Time.now
@@ -15,6 +16,7 @@ module Rails
15
16
 
16
17
  protected
17
18
  def before_dispatch(env, start_time)
19
+ TimeBandits.reset
18
20
  Thread.current[:time_bandits_completed_info] = nil
19
21
 
20
22
  request = ActionDispatch::Request.new(env)
@@ -26,7 +28,7 @@ module Rails
26
28
 
27
29
  def after_dispatch(env, result, run_time)
28
30
  status = result ? result.first : 500
29
- duration, additions = Thread.current[:time_bandits_completed_info]
31
+ duration, additions, view_time, action = Thread.current[:time_bandits_completed_info]
30
32
 
31
33
  message = "Completed #{status} #{::Rack::Utils::HTTP_STATUS_CODES[status]} in %.1fms" % (run_time*1000)
32
34
  message << " (#{additions.join(' | ')})" unless additions.blank?
@@ -1,9 +1,11 @@
1
1
  module TimeBandits
2
2
  class Railtie < Rails::Railtie
3
3
 
4
- initializer "time_bandits" do
4
+ initializer "time_bandits" do |app|
5
+ app.config.middleware.swap("Rails::Rack::Logger", "TimeBandits::Rack::Logger")
6
+
5
7
  ActiveSupport.on_load(:action_controller) do
6
- require 'time_bandits/monkey_patches/rails_rack_logger'
8
+ require 'time_bandits/rack/logger.rb'
7
9
  require 'time_bandits/monkey_patches/action_controller'
8
10
  include ActionController::TimeBanditry
9
11
  end
@@ -1,3 +1,3 @@
1
1
  module TimeBandits
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time_bandits
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Stefan Kaes
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-28 00:00:00 +02:00
18
+ date: 2011-09-04 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -58,7 +58,7 @@ files:
58
58
  - lib/time_bandits/monkey_patches/active_record_rails2.rb
59
59
  - lib/time_bandits/monkey_patches/memcache-client.rb
60
60
  - lib/time_bandits/monkey_patches/memcached.rb
61
- - lib/time_bandits/monkey_patches/rails_rack_logger.rb
61
+ - lib/time_bandits/rack/logger.rb
62
62
  - lib/time_bandits/railtie.rb
63
63
  - lib/time_bandits/time_consumers/database.rb
64
64
  - lib/time_bandits/time_consumers/database_rails2.rb