time_bandits 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,23 +5,17 @@ module Rails
5
5
  class Logger
6
6
 
7
7
  def call(env)
8
- Thread.current[:time_bandits_completed_info] = nil
9
8
  start_time = before_dispatch(env)
10
9
  result = @app.call(env)
11
10
  ensure
12
11
  run_time = Time.now - start_time
13
- status = result.first
14
- duration, additions = Thread.current[:time_bandits_completed_info]
15
- (additions ||= []).insert(0, "Controller: %.1fms" % duration)
16
-
17
- message = "Completed #{status} #{::Rack::Utils::HTTP_STATUS_CODES[status]} in %.1fms (#{additions.join(' | ')})" % (run_time*1000)
18
- info message
19
-
20
- after_dispatch(env)
12
+ after_dispatch(env, result, run_time)
21
13
  end
22
14
 
23
15
  protected
24
16
  def before_dispatch(env)
17
+ Thread.current[:time_bandits_completed_info] = nil
18
+
25
19
  start_time = Time.now
26
20
  request = ActionDispatch::Request.new(env)
27
21
  path = request.fullpath
@@ -31,6 +25,16 @@ module Rails
31
25
  start_time
32
26
  end
33
27
 
28
+ def after_dispatch(env, result, run_time)
29
+ status = result.first
30
+ duration, additions = Thread.current[:time_bandits_completed_info]
31
+
32
+ message = "Completed #{status} #{::Rack::Utils::HTTP_STATUS_CODES[status]} in %.1fms (#{additions.join(' | ')})" % (run_time*1000)
33
+ info message
34
+
35
+ ActiveSupport::LogSubscriber.flush_all!
36
+ end
37
+
34
38
  end
35
39
  end
36
40
  end
@@ -1,3 +1,3 @@
1
1
  module TimeBandits
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time_bandits
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 1
10
- version: 0.0.1
4
+ prerelease:
5
+ version: 0.0.2
11
6
  platform: ruby
12
7
  authors:
13
8
  - Stefan Kaes
@@ -15,7 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-03-29 00:00:00 +02:00
13
+ date: 2011-03-30 00:00:00 +02:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
@@ -26,10 +21,6 @@ dependencies:
26
21
  requirements:
27
22
  - - ~>
28
23
  - !ruby/object:Gem::Version
29
- hash: 7
30
- segments:
31
- - 3
32
- - 0
33
24
  version: "3.0"
34
25
  type: :runtime
35
26
  version_requirements: *id001
@@ -75,23 +66,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
66
  requirements:
76
67
  - - ">="
77
68
  - !ruby/object:Gem::Version
78
- hash: 3
79
- segments:
80
- - 0
81
69
  version: "0"
82
70
  required_rubygems_version: !ruby/object:Gem::Requirement
83
71
  none: false
84
72
  requirements:
85
73
  - - ">="
86
74
  - !ruby/object:Gem::Version
87
- hash: 3
88
- segments:
89
- - 0
90
75
  version: "0"
91
76
  requirements: []
92
77
 
93
78
  rubyforge_project: time_bandits
94
- rubygems_version: 1.3.7
79
+ rubygems_version: 1.5.3
95
80
  signing_key:
96
81
  specification_version: 3
97
82
  summary: Custom performance logging for Rails