active_record_query_trace 1.1 → 1.2

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.
data/README.md CHANGED
@@ -3,7 +3,7 @@ Logs the source of execution of all queries to the Rails log. Helpful to track d
3
3
  Install
4
4
  -------
5
5
 
6
- `gem install active_query_record_trace`
6
+ `gem install active_record_query_trace`
7
7
 
8
8
  Usage
9
9
  -----
@@ -11,9 +11,23 @@ Usage
11
11
  Enable it in an initializer:
12
12
 
13
13
  ```ruby
14
- ActiveQueryRecordTrace.enabled = true
14
+ ActiveRecordQueryTrace.enabled = true
15
+
16
+ # Optional
17
+ ActiveRecordQueryTrace.level = :app (default)
18
+ ActiveRecordQueryTrace.level = :full (alternate ouput of full backtrace, useful for debugging gems)
15
19
  ```
16
20
 
21
+ Output
22
+ ------
23
+
24
+ When enabled every query source will be logged like:
25
+
26
+ ```
27
+ IntuitAccount Load (1.2ms) SELECT "intuit_accounts".* FROM "intuit_accounts" WHERE "intuit_accounts"."user_id" = 20 LIMIT 1
28
+ Called from: app/views/users/edit.html.haml:78:in `block in _app_views_users_edit_html_haml___1953197429694975654_70177901460360'
29
+ app/views/users/edit.html.haml:16:in `_app_views_users_edit_html_haml___1953197429694975654_70177901460360'
30
+ ```
17
31
 
18
32
  Requirements
19
33
  ------------
@@ -0,0 +1,15 @@
1
+ $:.unshift File.expand_path("../lib", __FILE__)
2
+ require 'version'
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'active_record_query_trace'
6
+ gem.version = ActiveRecordQueryTrace::VERSION
7
+
8
+ gem.summary = "Print stack trace of all queries to the Rails log. Helpful to find where queries are being executed in your application."
9
+ gem.description = gem.summary
10
+ gem.authors = ["Cody Caughlan"]
11
+ gem.email = 'toolbag@gmail.com'
12
+ gem.homepage = 'https://github.com/ruckus/active-record-query-trace'
13
+ gem.files = Dir["**/*"]
14
+
15
+ end
@@ -4,6 +4,7 @@ module ActiveRecordQueryTrace
4
4
 
5
5
  class << self
6
6
  attr_accessor :enabled
7
+ attr_accessor :level
7
8
  end
8
9
 
9
10
  module ActiveRecord
@@ -12,19 +13,24 @@ module ActiveRecordQueryTrace
12
13
  def initialize
13
14
  super
14
15
  ActiveRecordQueryTrace.enabled = false
16
+ ActiveRecordQueryTrace.level = :app
15
17
  end
16
18
 
17
19
  def sql(event)
18
20
  if ActiveRecordQueryTrace.enabled
19
- debug("\e[1m\e[35m\e[1m\e[47mCalled from:\e[0m " + clean_trace(caller[2..-2]).join("\n "))
21
+ debug("\e[1m\e[35m\e[1m\e[47mCalled from:\e[0m " + clean_trace(caller).join("\n "))
20
22
  end
21
23
  end
22
24
 
23
25
  def clean_trace(trace)
24
- Rails.respond_to?(:backtrace_cleaner) ? Rails.backtrace_cleaner.clean(trace) : trace
26
+ if ActiveRecordQueryTrace.level == :full
27
+ trace
28
+ else
29
+ Rails.respond_to?(:backtrace_cleaner) ? Rails.backtrace_cleaner.clean(trace) : trace
30
+ end
25
31
  end
26
32
 
27
33
  attach_to :active_record
28
34
  end
29
35
  end
30
- end
36
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module ActiveRecordQueryTrace
2
+ VERSION = '1.2'
3
+ end
metadata CHANGED
@@ -1,65 +1,50 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: active_record_query_trace
3
- version: !ruby/object:Gem::Version
4
- hash: 13
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.2'
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 1
9
- version: "1.1"
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Cody Caughlan
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-11-19 00:00:00 Z
12
+ date: 2013-04-02 00:00:00.000000000 Z
18
13
  dependencies: []
19
-
20
- description: Print stack trace of all queries to the Rails log. Helpful to find where queries are being executed in your application.
14
+ description: Print stack trace of all queries to the Rails log. Helpful to find where
15
+ queries are being executed in your application.
21
16
  email: toolbag@gmail.com
22
17
  executables: []
23
-
24
18
  extensions: []
25
-
26
19
  extra_rdoc_files: []
27
-
28
- files:
29
- - README.md
20
+ files:
21
+ - active_record_query_trace.gemspec
30
22
  - lib/active_record_query_trace.rb
23
+ - lib/version.rb
24
+ - README.md
31
25
  homepage: https://github.com/ruckus/active-record-query-trace
32
26
  licenses: []
33
-
34
27
  post_install_message:
35
28
  rdoc_options: []
36
-
37
- require_paths:
29
+ require_paths:
38
30
  - lib
39
- required_ruby_version: !ruby/object:Gem::Requirement
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
40
36
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- version: "0"
48
- required_rubygems_version: !ruby/object:Gem::Requirement
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
49
42
  none: false
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- hash: 3
54
- segments:
55
- - 0
56
- version: "0"
57
43
  requirements: []
58
-
59
44
  rubyforge_project:
60
- rubygems_version: 1.8.17
45
+ rubygems_version: 1.8.24
61
46
  signing_key:
62
47
  specification_version: 3
63
- summary: Print stack trace of all queries to the Rails log. Helpful to find where queries are being executed in your application.
48
+ summary: Print stack trace of all queries to the Rails log. Helpful to find where
49
+ queries are being executed in your application.
64
50
  test_files: []
65
-