lograge-sql 1.3.0 → 1.3.1

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
2
  SHA256:
3
- metadata.gz: 2a1b24c2960cc4eecd3b3ca23807587a396e8b483c76e916b8f2a50b600babe2
4
- data.tar.gz: 5e33f26703504065a0838c5bb97f9bb45705a7ffce6317d2d239f46967b9fe79
3
+ metadata.gz: c5983447366cf1c996e3f4a6571646b4d54298df7e8c54417c02537c23b5132f
4
+ data.tar.gz: 48b16b073f9681e809eb3d1bcf3bb0f661ca2ae80a2a2958ef1d9ce495a1147e
5
5
  SHA512:
6
- metadata.gz: ee641c7c4988772cf1db3fb37639072e53c4cbe2a6a0b2823637e54f39a5ecba62ab1a52017f0a9418c61091af7419116ff36273f8363813090a45f65bea3a13
7
- data.tar.gz: 176fd786ad019f0cf125bbe9a77acbce82722d43f6df0421eeeb0d9b719116e2d0aa68f8a8589e5ddcbc76d32bba183c7bb6d0342ffda993d4719d8d703af7d5
6
+ metadata.gz: 1d53aade24130437f98e9bd7d06c448be1364cff17c6dc18c44da939723145a938246c15407fdb8644447d2be31824d34f52cafc0260dc3528b4674cf1a888b9
7
+ data.tar.gz: 9a8b3bbaa5abd569373b97ffbda2f1c8b2493be8c35695935587ae7726ac7af35adeb99caa01e2a03e753e26777d077c8f561fed1fa7d357568771094dcd4928
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lograge
4
+ # Log subscriber to replace ActiveRecord's default one
5
+ class ActiveRecordLogSubscriber < ActiveSupport::LogSubscriber
6
+ # Every time there's an SQL query, stores it into the Thread.
7
+ # They'll later be access from the RequestLogSubscriber.
8
+ def sql(event)
9
+ ActiveRecord::LogSubscriber.runtime += event.duration
10
+ return if event.payload[:name] == 'SCHEMA'
11
+
12
+ Lograge::Sql.store[:lograge_sql_queries] ||= []
13
+ Lograge::Sql.store[:lograge_sql_queries] << Lograge::Sql.extract_event.call(event)
14
+ end
15
+ end
16
+ end
@@ -17,14 +17,16 @@ module Lograge
17
17
  Lograge::Sql.formatter = config.formatter || default_formatter
18
18
  Lograge::Sql.extract_event = config.extract_event || default_extract_event
19
19
 
20
- return if config.keep_default_active_record_log
21
-
22
20
  # Disable existing ActiveRecord logging
23
- ActiveSupport::LogSubscriber.log_subscribers.each do |subscriber|
24
- Lograge.unsubscribe(:active_record, subscriber) if subscriber.is_a?(ActiveRecord::LogSubscriber)
21
+ unless config.keep_default_active_record_log
22
+ ActiveSupport::LogSubscriber.log_subscribers.each do |subscriber|
23
+ Lograge.unsubscribe(:active_record, subscriber) if subscriber.is_a?(ActiveRecord::LogSubscriber)
24
+ end
25
25
  end
26
26
 
27
- Lograge::ActiveRecordLogSubscriber.attach_to :active_record
27
+ return unless defined?(Lograge::ActiveRecordLogSubscriber)
28
+
29
+ Lograge::ActiveRecordLogSubscriber.attach_to(:active_record)
28
30
  end
29
31
 
30
32
  # Gets the store, preferring RequestStore if the gem is found.
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'lograge/active_record_log_subscriber'
4
+
3
5
  module Lograge
4
6
  module Sql
5
7
  # Module used to extend Lograge
@@ -24,21 +26,6 @@ module Lograge
24
26
  end
25
27
  end
26
28
 
27
- module Lograge
28
- # Log subscriber to replace ActiveRecord's default one
29
- class ActiveRecordLogSubscriber < ActiveSupport::LogSubscriber
30
- # Every time there's an SQL query, stores it into the Thread.
31
- # They'll later be access from the RequestLogSubscriber.
32
- def sql(event)
33
- ActiveRecord::LogSubscriber.runtime += event.duration
34
- return if event.payload[:name] == 'SCHEMA'
35
-
36
- Lograge::Sql.store[:lograge_sql_queries] ||= []
37
- Lograge::Sql.store[:lograge_sql_queries] << Lograge::Sql.extract_event.call(event)
38
- end
39
- end
40
- end
41
-
42
29
  if defined?(Lograge::RequestLogSubscriber)
43
30
  Lograge::RequestLogSubscriber.prepend Lograge::Sql::Extension
44
31
  else
@@ -3,6 +3,6 @@
3
3
  module Lograge
4
4
  module Sql
5
5
  # Gem version
6
- VERSION = '1.3.0'
6
+ VERSION = '1.3.1'
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lograge-sql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattia Giuffrida
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-14 00:00:00.000000000 Z
11
+ date: 2020-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -67,6 +67,7 @@ extra_rdoc_files: []
67
67
  files:
68
68
  - README.md
69
69
  - Rakefile
70
+ - lib/lograge/active_record_log_subscriber.rb
70
71
  - lib/lograge/sql.rb
71
72
  - lib/lograge/sql/extension.rb
72
73
  - lib/lograge/sql/railtie.rb