query_trail 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +22 -0
- data/Rakefile +1 -0
- data/lib/query_trail.rb +6 -0
- data/lib/query_trail/log_subscriber.rb +31 -0
- data/query_trail.gemspec +19 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 053f0958d308f2bdc9fb651e16563055efa6c64d
|
4
|
+
data.tar.gz: 3d77bcd64019746006d36720c024fd00dd7c3b41
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 84c5705b16fe6fb5a2847550b4ca9b327bc146e7b2f1ec99db43eb9b1f81dfbc134ea6843191ef146746a3d618f3bf80a887d15aa0f1a8c868416b810a2c264a
|
7
|
+
data.tar.gz: b2eba93db915fe38d9e27b5dbb0586b09ed86f317ff58cc803443bf23a9af67b777247972daf431ad284d000b065cce18381f7a3086077f9826d13ee4487510f
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Dmitry Vorotilin
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
## QueryTrail for Rails ~> 4.0
|
2
|
+
|
3
|
+
Shows a backtrace of your queries:
|
4
|
+
|
5
|
+
```
|
6
|
+
User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
|
7
|
+
Query Trail: config/initializers/warden.rb:11:in `block in <top (required)>'
|
8
|
+
config/initializers/warden.rb:15:in `block in <top (required)>'
|
9
|
+
Doc Load (18.2ms) SELECT `docs`.* FROM `docs` WHERE `docs`.`approved` = 1
|
10
|
+
Query Trail: app/views/main/_docs.html.erb:2
|
11
|
+
app/helpers/docs_helper.rb:3:in `render_main_block'
|
12
|
+
app/views/main/index.html.erb:13
|
13
|
+
app/views/main/index.html.erb:9
|
14
|
+
```
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
group :development do
|
20
|
+
gem 'query_trail', github: 'route/query_trail'
|
21
|
+
end
|
22
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/lib/query_trail.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module QueryTrail
|
2
|
+
class LogSubscriber < ActiveSupport::LogSubscriber
|
3
|
+
HEADER = " \e[1m\e[34mQuery Trail:\e[0m "
|
4
|
+
IGNORE_PAYLOAD_NAMES = ActiveRecord::LogSubscriber::IGNORE_PAYLOAD_NAMES
|
5
|
+
|
6
|
+
def sql(event)
|
7
|
+
return unless logger.debug?
|
8
|
+
payload = event.payload
|
9
|
+
return if IGNORE_PAYLOAD_NAMES.include?(payload[:name])
|
10
|
+
|
11
|
+
if backtrace = backtrace_cleaner.clean(caller).presence
|
12
|
+
logger.debug HEADER + backtrace.shift
|
13
|
+
logger.debug backtrace.map { |line| ' ' * (HEADER.size - 13) + line }.join("\n")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def logger
|
20
|
+
ActiveRecord::Base.logger
|
21
|
+
end
|
22
|
+
|
23
|
+
def backtrace_cleaner
|
24
|
+
@backtrace_cleaner ||= begin
|
25
|
+
backtrace_cleaner = Rails::BacktraceCleaner.new
|
26
|
+
backtrace_cleaner.add_filter { |line| line.sub(/(app\/views.*:\d+):in.*/, '\1') }
|
27
|
+
backtrace_cleaner
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/query_trail.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = 'query_trail'
|
3
|
+
spec.version = '1.0'
|
4
|
+
spec.authors = ['Dmitry Vorotilin']
|
5
|
+
spec.email = ['d.vorotilin@gmail.com']
|
6
|
+
spec.summary = "Shows the trace of your queries when they're fired"
|
7
|
+
spec.homepage = 'https://github.com/route/query_trail'
|
8
|
+
spec.license = 'MIT'
|
9
|
+
|
10
|
+
spec.files = `git ls-files -z`.split("\x0")
|
11
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
12
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
13
|
+
spec.require_paths = ['lib']
|
14
|
+
|
15
|
+
spec.add_runtime_dependency 'rails', '~> 4.0'
|
16
|
+
|
17
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
18
|
+
spec.add_development_dependency 'rake'
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: query_trail
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dmitry Vorotilin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- d.vorotilin@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/query_trail.rb
|
68
|
+
- lib/query_trail/log_subscriber.rb
|
69
|
+
- query_trail.gemspec
|
70
|
+
homepage: https://github.com/route/query_trail
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 2.2.2
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: Shows the trace of your queries when they're fired
|
94
|
+
test_files: []
|