active_record_query_trace 1.2 → 1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/README.md +18 -3
- data/lib/active_record_query_trace.rb +17 -3
- data/lib/version.rb +1 -1
- metadata +5 -7
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZTBiMjU5ZWY5Y2YwMmY3ZjBlNmMyY2YyMjI4MmQ5MzU5MTEwNWY0ZA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OTM5OWM3YWM5Y2E1OTViMTY0MDM4NWM3ODkwOWFmZmRmYzdjOGJkZg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YmExM2U2OTk5M2U1YTA0MDM4YmI1MWFlM2E5NjhlZDkxN2EzZjEwY2M0NGFl
|
10
|
+
MmY4M2Q5MDcyNzQwMDNjYjcyYjhhYTViODhmYTMwMTE4MjdlMDkxYTQyNGI2
|
11
|
+
MGY0OWRmZGQ4YWM1MzhkMTg4OWUwMTUyMzVmODhhNjVjNmM3MTU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MDk2NjUxZWViMmI0NjY4ODc4NjY3NTg5YTU4N2ViOWMyNmUzZDhkZTFkZDNm
|
14
|
+
NTMyMGJlZDg5N2YwM2Q4MWUyZmFkYjM2ZDA2OGMwYWY3MTdiNmM3MzFmODU3
|
15
|
+
Y2VjZjY0YzZhZDBjOGRkYzQxMzIwZDllNDZkOTFiZmQyMzA0OWM=
|
data/README.md
CHANGED
@@ -12,10 +12,25 @@ Enable it in an initializer:
|
|
12
12
|
|
13
13
|
```ruby
|
14
14
|
ActiveRecordQueryTrace.enabled = true
|
15
|
+
```
|
16
|
+
|
17
|
+
Options
|
18
|
+
_______
|
19
|
+
|
20
|
+
There are three levels of debug.
|
15
21
|
|
16
|
-
|
17
|
-
|
18
|
-
|
22
|
+
1. app - includes only files in your app/ directory.
|
23
|
+
2. full - includes files in your app as well as rails.
|
24
|
+
3. rails - alternate ouput of full backtrace, useful for debugging gems.
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
ActiveRecordQueryTrace.level = :app # default
|
28
|
+
```
|
29
|
+
|
30
|
+
Additionally, if you are working with a large app, you may wish to limit the number of lines displayed for each query.
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
ActiveRecordQueryTrace.lines = 10 # Default is 5. Setting to 0 includes entire trace.
|
19
34
|
```
|
20
35
|
|
21
36
|
Output
|
@@ -5,6 +5,7 @@ module ActiveRecordQueryTrace
|
|
5
5
|
class << self
|
6
6
|
attr_accessor :enabled
|
7
7
|
attr_accessor :level
|
8
|
+
attr_accessor :lines
|
8
9
|
end
|
9
10
|
|
10
11
|
module ActiveRecord
|
@@ -14,19 +15,32 @@ module ActiveRecordQueryTrace
|
|
14
15
|
super
|
15
16
|
ActiveRecordQueryTrace.enabled = false
|
16
17
|
ActiveRecordQueryTrace.level = :app
|
18
|
+
ActiveRecordQueryTrace.lines = 5
|
17
19
|
end
|
18
20
|
|
19
21
|
def sql(event)
|
20
22
|
if ActiveRecordQueryTrace.enabled
|
21
|
-
|
23
|
+
index = begin
|
24
|
+
if ActiveRecordQueryTrace.lines == 0
|
25
|
+
0..-1
|
26
|
+
else
|
27
|
+
0..(ActiveRecordQueryTrace.lines - 1)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
debug(color('Called from: ', MAGENTA, true) + clean_trace(caller)[index].join("\n "))
|
22
32
|
end
|
23
33
|
end
|
24
34
|
|
25
35
|
def clean_trace(trace)
|
26
|
-
|
36
|
+
case ActiveRecordQueryTrace.level
|
37
|
+
when :full
|
27
38
|
trace
|
28
|
-
|
39
|
+
when :rails
|
29
40
|
Rails.respond_to?(:backtrace_cleaner) ? Rails.backtrace_cleaner.clean(trace) : trace
|
41
|
+
when :app
|
42
|
+
Rails.backtrace_cleaner.add_silencer { |line| not line =~ /^app/ }
|
43
|
+
Rails.backtrace_cleaner.clean(trace)
|
30
44
|
end
|
31
45
|
end
|
32
46
|
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_query_trace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
5
|
-
prerelease:
|
4
|
+
version: '1.3'
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Cody Caughlan
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-08-16 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: Print stack trace of all queries to the Rails log. Helpful to find where
|
15
14
|
queries are being executed in your application.
|
@@ -24,6 +23,7 @@ files:
|
|
24
23
|
- README.md
|
25
24
|
homepage: https://github.com/ruckus/active-record-query-trace
|
26
25
|
licenses: []
|
26
|
+
metadata: {}
|
27
27
|
post_install_message:
|
28
28
|
rdoc_options: []
|
29
29
|
require_paths:
|
@@ -33,18 +33,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
33
33
|
- - ! '>='
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: '0'
|
36
|
-
none: false
|
37
36
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
37
|
requirements:
|
39
38
|
- - ! '>='
|
40
39
|
- !ruby/object:Gem::Version
|
41
40
|
version: '0'
|
42
|
-
none: false
|
43
41
|
requirements: []
|
44
42
|
rubyforge_project:
|
45
|
-
rubygems_version:
|
43
|
+
rubygems_version: 2.0.5
|
46
44
|
signing_key:
|
47
|
-
specification_version:
|
45
|
+
specification_version: 4
|
48
46
|
summary: Print stack trace of all queries to the Rails log. Helpful to find where
|
49
47
|
queries are being executed in your application.
|
50
48
|
test_files: []
|