sql-logging 3.0.10 → 3.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9aac99fce0362d4f0b07f0035ec9266dc97e1599
4
- data.tar.gz: 0c63f55de965eabc0216a84cad8f889eebbb9d58
2
+ SHA256:
3
+ metadata.gz: f2cb4888d60283e8bb85c45f6783506ee37706d0172f170dfcac727075c25d53
4
+ data.tar.gz: 2c5039a94905ef23aaa3f0b4c089712eae95a8618159695e79b2eba7173a4614
5
5
  SHA512:
6
- metadata.gz: f135c72dd4b332fcf9e2f08b0ac4fb167090003d1a22ff161c0925f4d9910f973f51a0774e50426d022a3784eb32177ce749f181a7b84468e6e6afe433310335
7
- data.tar.gz: 688b7ddf99783b4411d74ea76360775509871654a04e9dbf402fa8afad65a552112e4358f92562989a6f76699207c2be47b6e9b36682618d7b848040d99639b0
6
+ metadata.gz: 1ba76d7926d1d6f7dee3019ed9ade10ac0c261a7986d6c6476283a12750e46082c6324d41fb49b1b8c01c95b574dfef2fd31a317f07f012ea98bc510edf70b91
7
+ data.tar.gz: 0602bf7b0917bb47cd4d20c5bd320574d0f6b39fe0381716f5c46ec6e98e64390bebdc7a78f39324ef0d726d42d07aa65283ec638ac2f679210311eae5bb6902
@@ -7,7 +7,7 @@ is a repackaging of the old SQL Logging plug-in for Rails 2.x. It, in turn,
7
7
  was based on ideas and plug-ins from Adam Doppelt's (standard logging
8
8
  enhancements) and Nathaniel Talbott (the QueryTrace plug-in).
9
9
 
10
- This gem is for Rails 3+ only. It supports MySQL (including the mysql2 gem),
10
+ This gem is for Rails 4+ only. It supports MySQL (including the mysql2 gem),
11
11
  PostgreSQL and SQLite.
12
12
 
13
13
  == Usage
@@ -1,21 +1,25 @@
1
1
  require 'active_record/connection_adapters/abstract/query_cache'
2
2
 
3
3
  module ActiveRecord::ConnectionAdapters::QueryCache
4
- private
5
-
6
- def cache_sql_with_sql_logging(sql, binds, &blk)
7
- if @query_cache.has_key?(sql)
8
- rows = nil
9
- elapsed = Benchmark.measure do
10
- rows = cache_sql_without_sql_logging(sql, binds, &blk)
4
+ module CacheSQLWithSqlLogging
5
+ def cache_sql(sql, binds, &blk)
6
+ if @query_cache.has_key?(sql)
7
+ rows = nil
8
+ elapsed = Benchmark.measure do
9
+ rows = super(sql, binds, &blk)
10
+ end
11
+ msec = elapsed.real * 1000
12
+ SqlLogging::Statistics.record_query(sql, "CACHE", msec, rows)
13
+ rows
14
+ else
15
+ super(sql, binds, &blk)
11
16
  end
12
- msec = elapsed.real * 1000
13
- SqlLogging::Statistics.record_query(sql, "CACHE", msec, rows)
14
- rows
15
- else
16
- cache_sql_without_sql_logging(sql, binds, &blk)
17
17
  end
18
18
  end
19
19
 
20
- alias_method_chain :cache_sql, :sql_logging
20
+ private
21
+
22
+ def self.included(klass)
23
+ klass.prepend CacheSQLWithSqlLogging
24
+ end
21
25
  end
@@ -1,15 +1,19 @@
1
1
  require 'active_record/connection_adapters/mysql_adapter'
2
2
 
3
- class ActiveRecord::ConnectionAdapters::MysqlAdapter
4
- def select_with_sql_logging(sql, *args)
5
- rows = nil
6
- elapsed = Benchmark.measure do
7
- rows = select_without_sql_logging(sql, *args)
3
+ module ActiveRecord::ConnectionAdapters
4
+ module SelectWithSqlLogging
5
+ def select(sql, *args)
6
+ rows = nil
7
+ elapsed = Benchmark.measure do
8
+ rows = super(sql, *args)
9
+ end
10
+ msec = elapsed.real * 1000
11
+ SqlLogging::Statistics.record_query(sql, args.first, msec, rows)
12
+ rows
8
13
  end
9
- msec = elapsed.real * 1000
10
- SqlLogging::Statistics.record_query(sql, args.first, msec, rows)
11
- rows
12
14
  end
13
-
14
- alias_method_chain :select, :sql_logging
15
+
16
+ class MysqlAdapter
17
+ prepend SelectWithSqlLogging
18
+ end
15
19
  end
@@ -1,15 +1,19 @@
1
1
  require 'active_record/connection_adapters/mysql2_adapter'
2
2
 
3
- class ActiveRecord::ConnectionAdapters::Mysql2Adapter
4
- def select_with_sql_logging(sql, *args)
5
- rows = nil
6
- elapsed = Benchmark.measure do
7
- rows = select_without_sql_logging(sql, *args)
3
+ module ActiveRecord::ConnectionAdapters
4
+ module SelectWithSqlLogging
5
+ def select(sql, *args)
6
+ rows = nil
7
+ elapsed = Benchmark.measure do
8
+ rows = super(sql, *args)
9
+ end
10
+ msec = elapsed.real * 1000
11
+ SqlLogging::Statistics.record_query(sql, args.first, msec, rows)
12
+ rows
8
13
  end
9
- msec = elapsed.real * 1000
10
- SqlLogging::Statistics.record_query(sql, args.first, msec, rows)
11
- rows
12
14
  end
13
-
14
- alias_method_chain :select, :sql_logging
15
+
16
+ class Mysql2Adapter
17
+ prepend SelectWithSqlLogging
18
+ end
15
19
  end
@@ -1,15 +1,19 @@
1
1
  require 'active_record/connection_adapters/pedant_mysql2_adapter'
2
2
 
3
- class ActiveRecord::ConnectionAdapters::Mysql2Adapter
4
- def select_with_sql_logging(sql, *args)
5
- rows = nil
6
- elapsed = Benchmark.measure do
7
- rows = select_without_sql_logging(sql, *args)
3
+ module ActiveRecord::ConnectionAdapters
4
+ module SelectWithSqlLogging
5
+ def select(sql, *args)
6
+ rows = nil
7
+ elapsed = Benchmark.measure do
8
+ rows = super(sql, *args)
9
+ end
10
+ msec = elapsed.real * 1000
11
+ SqlLogging::Statistics.record_query(sql, args.first, msec, rows)
12
+ rows
8
13
  end
9
- msec = elapsed.real * 1000
10
- SqlLogging::Statistics.record_query(sql, args.first, msec, rows)
11
- rows
12
14
  end
13
15
 
14
- alias_method_chain :select, :sql_logging
16
+ class Mysql2Adapter
17
+ prepend SelectWithSqlLogging
18
+ end
15
19
  end
@@ -1,45 +1,53 @@
1
1
  require 'active_record/connection_adapters/postgresql_adapter'
2
2
 
3
- class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
4
- def execute_with_sql_logging(sql, *args)
5
- result = nil
6
- elapsed = Benchmark.measure do
7
- result = execute_without_sql_logging(sql, *args)
3
+ module ActiveRecord::ConnectionAdapters
4
+ module ExecuteWithSqlLogging
5
+ def execute(sql, *args)
6
+ result = nil
7
+ elapsed = Benchmark.measure do
8
+ result = super(sql, *args)
9
+ end
10
+ msec = elapsed.real * 1000
11
+ if result.respond_to?(:rows)
12
+ SqlLogging::Statistics.record_query(sql, args.first, msec, result.rows)
13
+ else
14
+ SqlLogging::Statistics.record_query(sql, args.first, msec, result)
15
+ end
16
+ result
8
17
  end
9
- msec = elapsed.real * 1000
10
- if result.respond_to?(:rows)
11
- SqlLogging::Statistics.record_query(sql, args.first, msec, result.rows)
12
- else
13
- SqlLogging::Statistics.record_query(sql, args.first, msec, result)
14
- end
15
- result
16
18
  end
17
-
18
- def exec_query_with_sql_logging(sql, *args)
19
- result = nil
20
- elapsed = Benchmark.measure do
21
- result = exec_query_without_sql_logging(sql, *args)
19
+
20
+ module ExecQueryWithSqlLogging
21
+ def exec_query(sql, *args)
22
+ result = nil
23
+ elapsed = Benchmark.measure do
24
+ result = super(sql, *args)
25
+ end
26
+ msec = elapsed.real * 1000
27
+ if result.respond_to?(:rows)
28
+ SqlLogging::Statistics.record_query(sql, args.first, msec, result.rows)
29
+ else
30
+ SqlLogging::Statistics.record_query(sql, args.first, msec, result)
31
+ end
32
+ result
22
33
  end
23
- msec = elapsed.real * 1000
24
- if result.respond_to?(:rows)
25
- SqlLogging::Statistics.record_query(sql, args.first, msec, result.rows)
26
- else
34
+ end
35
+
36
+ module ExecDeleteWithSqlLogging
37
+ def exec_delete(sql, *args)
38
+ result = nil
39
+ elapsed = Benchmark.measure do
40
+ result = super(sql, *args)
41
+ end
42
+ msec = elapsed.real * 1000
27
43
  SqlLogging::Statistics.record_query(sql, args.first, msec, result)
44
+ result
28
45
  end
29
- result
30
46
  end
31
-
32
- def exec_delete_with_sql_logging(sql, *args)
33
- result = nil
34
- elapsed = Benchmark.measure do
35
- result = exec_delete_without_sql_logging(sql, *args)
36
- end
37
- msec = elapsed.real * 1000
38
- SqlLogging::Statistics.record_query(sql, args.first, msec, result)
39
- result
47
+
48
+ class PostgreSQLAdapter
49
+ prepend ExecuteWithSqlLogging
50
+ prepend ExecQueryWithSqlLogging
51
+ prepend ExecDeleteWithSqlLogging
40
52
  end
41
-
42
- alias_method_chain :execute, :sql_logging
43
- alias_method_chain :exec_query, :sql_logging
44
- alias_method_chain :exec_delete, :sql_logging
45
53
  end
@@ -1,13 +1,17 @@
1
- class ActiveRecord::ConnectionAdapters::SQLiteAdapter
2
- def execute_with_sql_logging(sql, name = nil)
3
- res = nil
4
- elapsed = Benchmark.measure do
5
- res = execute_without_sql_logging(sql, name)
1
+ module ActiveRecord::ConnectionAdapters
2
+ module ExecuteWithSqlLogging
3
+ def execute(sql, name = nil)
4
+ res = nil
5
+ elapsed = Benchmark.measure do
6
+ res = super(sql, name)
7
+ end
8
+ msec = elapsed.real * 1000
9
+ SqlLogging::Statistics.record_query(sql, name, msec, res)
10
+ res
6
11
  end
7
- msec = elapsed.real * 1000
8
- SqlLogging::Statistics.record_query(sql, name, msec, res)
9
- res
10
12
  end
11
13
 
12
- alias_method_chain :execute, :sql_logging
14
+ class SQLiteAdapter
15
+ prepend ExecuteWithSqlLogging
16
+ end
13
17
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module SqlLogging
3
4
  class Configuration
4
5
  DEFAULTS = {
@@ -9,7 +10,7 @@ module SqlLogging
9
10
  logger: nil
10
11
  }.freeze
11
12
 
12
- attr_writer(*DEFAULTS.keys - [:show_top_sql_queries=])
13
+ attr_writer(*DEFAULTS.keys - [:show_top_sql_queries])
13
14
  attr_reader(*DEFAULTS.keys - %i(logger backtrace_cleaner))
14
15
 
15
16
  def initialize
@@ -6,12 +6,12 @@ module SqlLogging
6
6
  require "sql-logging/adapters/cache_extension"
7
7
  begin
8
8
  require "sql-logging/adapters/#{adapter}"
9
- rescue LoadError => e
9
+ rescue LoadError
10
10
  Rails.logger.warn "SQL Logging extensions are not available for #{adapter}; functionality will be limited"
11
11
  end
12
12
  end
13
13
  end
14
-
14
+
15
15
  initializer 'sql_logging.reset_statistics' do
16
16
  ActiveSupport.on_load(:active_record) do
17
17
  ActionDispatch::Callbacks.before do
@@ -1,3 +1,5 @@
1
+ require 'forwardable'
2
+
1
3
  module SqlLogging
2
4
  class Statistics
3
5
  class Data
@@ -1,3 +1,3 @@
1
1
  module SqlLogging
2
- VERSION = '3.0.10'
2
+ VERSION = '3.0.11'
3
3
  end
metadata CHANGED
@@ -1,64 +1,66 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sql-logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.10
4
+ version: 3.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Madsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-01 00:00:00.000000000 Z
11
+ date: 2018-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 2.11.0
47
+ version: 5.8.3
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 2.11.0
55
- description: Adds SQL analysis and debugging info to Rails 3 apps.
54
+ version: 5.8.3
55
+ description: Adds SQL analysis and debugging info to Rails applications.
56
56
  email: steve@lightyearsoftware.com
57
57
  executables: []
58
58
  extensions: []
59
59
  extra_rdoc_files:
60
60
  - README.rdoc
61
61
  files:
62
+ - README.rdoc
63
+ - lib/sql-logging.rb
62
64
  - lib/sql-logging/adapters/cache_extension.rb
63
65
  - lib/sql-logging/adapters/mysql.rb
64
66
  - lib/sql-logging/adapters/mysql2.rb
@@ -73,8 +75,6 @@ files:
73
75
  - lib/sql-logging/railtie.rb
74
76
  - lib/sql-logging/statistics.rb
75
77
  - lib/sql-logging/version.rb
76
- - lib/sql-logging.rb
77
- - README.rdoc
78
78
  homepage: http://github.com/lightyear/sql-logging
79
79
  licenses: []
80
80
  metadata: {}
@@ -84,18 +84,18 @@ require_paths:
84
84
  - lib
85
85
  required_ruby_version: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  requirements:
92
- - - '>='
92
+ - - ">="
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0'
95
95
  requirements: []
96
96
  rubyforge_project:
97
- rubygems_version: 2.0.14.1
97
+ rubygems_version: 2.7.6
98
98
  signing_key:
99
99
  specification_version: 4
100
- summary: Adds SQL analysis and debugging info to Rails 3 apps.
100
+ summary: SQL analysis and debugging info for Rails
101
101
  test_files: []