lograge-sql-one-line 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lograge/sql/extension.rb +9 -9
- data/lib/lograge/sql/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee098cd725561bbc5ab9fc259979d34c2d3bbcee
|
4
|
+
data.tar.gz: d4518423e8ea0fc3d12a7b866ebd948c52e39a49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 268b02326ebe8922fa01d268a0c881db841b9931c124b0bb7dde99e37e8b8a7706281d26bc648dc0f90317c60b9f9be8380ad9f53730a460567a420bacdb7a20
|
7
|
+
data.tar.gz: 60e7a136c28d4123d21563b6fff4c4e39ba2ef13ccdce6650c563499d074aa05decb631dc556080eb9515aa13b2aa72027e43a5a361ab91d04b6b158f21f4bb2
|
@@ -2,18 +2,20 @@ module Lograge
|
|
2
2
|
module Sql
|
3
3
|
module Extension
|
4
4
|
def extract_request(event, payload)
|
5
|
-
super.merge!(extract_sql_queries)
|
5
|
+
super.merge!(extract_sql_queries(payload[:uuid]))
|
6
6
|
end
|
7
7
|
|
8
|
-
def extract_sql_queries
|
8
|
+
def extract_sql_queries(uuid)
|
9
9
|
sql_queries = Thread.current[:lograge_sql_queries]
|
10
|
-
transaction_id = Thread.current[:transaction_id]
|
11
|
-
|
12
10
|
return {} unless sql_queries
|
13
11
|
|
14
|
-
Thread.current[:transaction_id] = nil
|
15
12
|
Thread.current[:lograge_sql_queries] = nil
|
16
|
-
|
13
|
+
|
14
|
+
sql_queries_with_uuid = sql_queries.map do |query|
|
15
|
+
"\n[#{uuid}] #{query}"
|
16
|
+
end
|
17
|
+
|
18
|
+
{ sql_queries: sql_queries_with_uuid.join }
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -25,9 +27,7 @@ module Lograge
|
|
25
27
|
ActiveRecord::LogSubscriber.runtime += event.duration
|
26
28
|
return if event.payload[:name] == 'SCHEMA'
|
27
29
|
Thread.current[:lograge_sql_queries] ||= []
|
28
|
-
Thread.current[:lograge_sql_queries] << ("
|
29
|
-
|
30
|
-
Thread.current[:transaction_id] ||= event.transaction_id
|
30
|
+
Thread.current[:lograge_sql_queries] << ("#{event.payload[:name]} (#{event.duration.to_f.round(2)}) #{event.payload[:sql]}")
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
data/lib/lograge/sql/version.rb
CHANGED