tracer_bullets 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OTdiM2Y0YjViYjcwZTkwMTNiZjM3MTNhYzExNDliYjc0NjZlMmE5YQ==
5
+ data.tar.gz: !binary |-
6
+ MmE3MmRiMjVkYjE4MTZlYjc2ZTYzNzJiNzIzNjM4OWE3MWUyMWEzYg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ YjJlMGZkZWE0ODBlNzNmMDUxNTIwNmI2NmI2NzIwOWNmYWFiMDU4YmE3ZDJh
10
+ OGIxZjY2MmQxMDE3N2QxZDBjMTE3Mzg3MjU2Yzk5NDk2OTMwMWI3NDIwNWNj
11
+ ZjY2ZjExMjhmOTI4NTAyNGVjYWE4MDI0YTU2NzQ3NTEyMjM2OWQ=
12
+ data.tar.gz: !binary |-
13
+ ODgyMDdmZWI0ZWQzZjUyYWVjODM1Y2NkYTkyMDEzYTllZDNiYjg5OGE2NjEz
14
+ MDVhNjU1MjRkYmZkMDE1ZmI1NmU5MWMyNjFiZWY4ZGZiYTYxMzUzZTUzNTcy
15
+ ZTM3MzdmM2NkNWJhNGQ2M2NhMzA2YTViZDViY2RiYjU5YWI3MGY=
data/README.md CHANGED
@@ -5,7 +5,7 @@ Tracer Bullets
5
5
 
6
6
  > [Wikipedia](http://en.wikipedia.org/wiki/Tracer_ammunition)
7
7
 
8
- Tracer Bullet is also an alter ego of Calvin in the comic strip Calvin and Hobbes. :)
8
+ Tracer Bullet is also a private investigator, an alter ego of Calvin in the comic strip Calvin and Hobbes. :)
9
9
 
10
10
  -----------------------
11
11
 
@@ -18,7 +18,7 @@ Performance tuning a Rails app is still pretty damn hard. There are great tools
18
18
 
19
19
  On the Obama re-election campaign, I did a ton of performance engineering, and the tool that helped me out the most was simply something I built to add "tracer bullets" to my code. These bullets were just method calls to log the current location of the program and how much time had elapsed since the last time it was called.
20
20
 
21
- I keep finding myself reinventing this same type of performance logging tool to solve performance bottlenecks in things I work on today, like **[Draft (an app to help people write better)](http://draftin.com)**
21
+ I keep finding myself reinventing this same type of performance logging tool to solve performance bottlenecks in things I work on today, like **[Draft](http://draftin.com) (an app to help people [write better](http://draftin.com))**
22
22
 
23
23
  So here's a really simple version I made for everyone to use. It gives you a method to call:
24
24
 
@@ -74,11 +74,11 @@ These traces only run in Development mode. So you can leave them in your code if
74
74
  Installation
75
75
  ------------
76
76
 
77
- 1) Add 'tracer_bullet' to your Gemfile. Probably best to just add it to your development group:
77
+ 1) Add 'tracer_bullets' to your Gemfile. Probably best to just add it to your development group:
78
78
 
79
79
  ```
80
80
  group :development do
81
- gem 'tracer_bullet'
81
+ gem 'tracer_bullets'
82
82
  end
83
83
  ```
84
84
 
@@ -100,3 +100,7 @@ or view code:
100
100
  Feedback
101
101
  --------
102
102
  [Source code available on Github](https://github.com/n8/tracer_bullets). Feedback and pull requests are greatly appreciated. Let me know if I can improve this.
103
+
104
+ -----------
105
+
106
+ P.S. [**I'd love to meet you on Twitter: here**](http://twitter.com/natekontny).
@@ -5,35 +5,42 @@ module TracerBullets
5
5
  module Methods
6
6
  def tracer_bullet
7
7
  if Rails.env.development?
8
- Rails.logger.debug( "Elapsed: #{((Time.now - @tracer_bullet_start_time)*1000).to_i}ms #{caller(0)[1]}" )
8
+ _tracer_bullets_log( "Elapsed: #{((Time.now - @tracer_bullet_start_time)*1000).to_i}ms #{caller(0)[1]}" )
9
9
  @tracer_bullet_start_time = Time.now
10
10
  end
11
11
  end
12
12
  alias_method :tb, :tracer_bullet
13
+
14
+ private
15
+
16
+ def _tracer_bullets_log(msg)
17
+ log = Rails.logger
18
+ if defined?(ActiveSupport::TaggedLogging)
19
+ log.tagged("TracerBullets") { |l| l.debug(msg) }
20
+ else
21
+ log.debug(msg)
22
+ end
23
+ end
13
24
  end
14
25
 
15
26
  module Controller
16
27
  extend ActiveSupport::Concern
28
+ include Methods
17
29
 
18
30
  included do
19
31
  before_filter :setup_tracer_bullet_start_time
20
32
  end
21
33
 
22
- module InstanceMethods
23
- include Methods
24
-
25
- def setup_tracer_bullet_start_time
26
- @tracer_bullet_start_time = Time.now
27
- end
34
+ def setup_tracer_bullet_start_time
35
+ @tracer_bullet_start_time = Time.now
28
36
  end
37
+
29
38
  end
30
39
 
31
40
  module View
32
41
  extend ActiveSupport::Concern
33
-
34
- module InstanceMethods
35
- include Methods
36
- end
42
+ include Methods
43
+
37
44
  end
38
45
 
39
46
 
@@ -1,3 +1,3 @@
1
1
  module TracerBullets
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tracer_bullets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 0.0.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - nate
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-31 00:00:00.000000000 Z
11
+ date: 2013-08-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
@@ -61,26 +56,25 @@ files:
61
56
  homepage: ''
62
57
  licenses:
63
58
  - MIT
59
+ metadata: {}
64
60
  post_install_message:
65
61
  rdoc_options: []
66
62
  require_paths:
67
63
  - lib
68
64
  required_ruby_version: !ruby/object:Gem::Requirement
69
- none: false
70
65
  requirements:
71
66
  - - ! '>='
72
67
  - !ruby/object:Gem::Version
73
68
  version: '0'
74
69
  required_rubygems_version: !ruby/object:Gem::Requirement
75
- none: false
76
70
  requirements:
77
71
  - - ! '>='
78
72
  - !ruby/object:Gem::Version
79
73
  version: '0'
80
74
  requirements: []
81
75
  rubyforge_project:
82
- rubygems_version: 1.8.23
76
+ rubygems_version: 2.0.6
83
77
  signing_key:
84
- specification_version: 3
78
+ specification_version: 4
85
79
  summary: A simple way to see time expiration in your Rails log files
86
80
  test_files: []