lines 0.1.26 → 0.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/CHANGELOG.md +6 -0
- data/lib/lines/active_record.rb +21 -4
- data/lib/lines/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTM0ODk2MzlkMTQ3YmJhMTc2MmI4MGMzNzYzNTQyMTFjNmQ5OTYyZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTA4YzE1ZTJkMjQwZDM0NmRiOGVlMDY1MzFkMmIxYmJhMzYxNzlmZA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWZlYzZmYzdhNjBjOTIwNGU2MjYyMjFmMjNkNGNjYzE1NmI2NTk2NzJlOGYx
|
10
|
+
MGRhNmU2ZjYxNWY3MGJlMWExMjVjYzEwMTBiZGU0MGFlMWIyNzEyNjE0NjQ4
|
11
|
+
YzA0Y2QwZTc4NmI4N2E3YmI4OGQwZDY4Y2E4OTI5NmI2N2FmNzY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NWFkZGFkNjY5OWE4NmViZWEzOWNhNzllNjZiZTg1NzI2YmFjNzRmOTYyNGE0
|
14
|
+
OTM4ZDA0YTc1ZmM5MzdmYzdlY2I0YzMwOTVhNDE0YTBjYjk5YzM0MjVhNGEw
|
15
|
+
NTUxOWIyOTkzOGExNDliZjY1ZTI0NTUyYzVlYjlkNTY3ZWE5Yzg=
|
data/CHANGELOG.md
CHANGED
data/lib/lines/active_record.rb
CHANGED
@@ -3,10 +3,22 @@ require 'lines'
|
|
3
3
|
|
4
4
|
module Lines
|
5
5
|
class ActiveRecordSubscriber < ActiveSupport::LogSubscriber
|
6
|
+
def render_bind(column, value)
|
7
|
+
if column
|
8
|
+
if column.binary?
|
9
|
+
value = "<#{value.bytesize} bytes of binary data>"
|
10
|
+
end
|
11
|
+
|
12
|
+
[column.name, value]
|
13
|
+
else
|
14
|
+
[nil, value]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
6
18
|
def sql(event)
|
7
19
|
payload = event.payload
|
8
20
|
|
9
|
-
return if payload[:name] == 'SCHEMA'
|
21
|
+
return if payload[:name] == 'SCHEMA' || payload[:name] == 'EXPLAIN'
|
10
22
|
|
11
23
|
args = {}
|
12
24
|
|
@@ -15,12 +27,13 @@ module Lines
|
|
15
27
|
|
16
28
|
if payload[:binds] && payload[:binds].any?
|
17
29
|
args[:binds] = payload[:binds].inject({}) do |hash,(col, v)|
|
18
|
-
|
30
|
+
k, v = render_bind(col, v)
|
31
|
+
hash[k] = v
|
19
32
|
hash
|
20
33
|
end
|
21
34
|
end
|
22
35
|
|
23
|
-
args[:elapsed] = [event.duration, '
|
36
|
+
args[:elapsed] = [event.duration.round(1), 'ms']
|
24
37
|
|
25
38
|
Lines.log(args)
|
26
39
|
end
|
@@ -33,6 +46,9 @@ module Lines
|
|
33
46
|
end
|
34
47
|
end
|
35
48
|
|
49
|
+
# Subscribe lines to the AR events
|
50
|
+
Lines::ActiveRecordSubscriber.attach_to :active_record
|
51
|
+
|
36
52
|
# Remove the default ActiveRecord::LogSubscriber to avoid double outputs
|
37
53
|
ActiveSupport::LogSubscriber.log_subscribers.each do |subscriber|
|
38
54
|
if subscriber.is_a?(ActiveRecord::LogSubscriber)
|
@@ -47,6 +63,7 @@ ActiveSupport::LogSubscriber.log_subscribers.each do |subscriber|
|
|
47
63
|
end
|
48
64
|
end
|
49
65
|
end
|
66
|
+
|
67
|
+
# Make sure it has a logger just in case
|
50
68
|
ActiveRecord::Base.logger = Lines.logger
|
51
|
-
Lines::ActiveRecordSubscriber.attach_to :active_record
|
52
69
|
|
data/lib/lines/version.rb
CHANGED