lines 0.1.26 → 0.1.27

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTY4ODEyZDBhZjRkNTgxY2JkOGI4NGY4ZDQ3Y2U5ZWQ0YmE5YTkyMg==
4
+ OTM0ODk2MzlkMTQ3YmJhMTc2MmI4MGMzNzYzNTQyMTFjNmQ5OTYyZQ==
5
5
  data.tar.gz: !binary |-
6
- NDc1NTBjMjY0ZTExNjJiNzIxNmI0YTgwZGJiZTRhNWFlODBhMTAzNg==
6
+ OTA4YzE1ZTJkMjQwZDM0NmRiOGVlMDY1MzFkMmIxYmJhMzYxNzlmZA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MThiZTY3ZTM4NDViYjFlNTQ5MmIyM2UwMjdiYTA2ZWVkMDMwYTA5NDk4MmM3
10
- OGU5N2FjYWYzYzAyMWJlZGZlNDM5NzA2NjA4N2YyNDNiYjk0MTg0ZGJhOWU2
11
- YWMzMzcxNjA5MmI1NjRlMGFiYjI2YTJlZWQwZWVhM2JmMGE2MzE=
9
+ YWZlYzZmYzdhNjBjOTIwNGU2MjYyMjFmMjNkNGNjYzE1NmI2NTk2NzJlOGYx
10
+ MGRhNmU2ZjYxNWY3MGJlMWExMjVjYzEwMTBiZGU0MGFlMWIyNzEyNjE0NjQ4
11
+ YzA0Y2QwZTc4NmI4N2E3YmI4OGQwZDY4Y2E4OTI5NmI2N2FmNzY=
12
12
  data.tar.gz: !binary |-
13
- NWVjNjgzZTE4MWNlNmEwNTA0NWM2NzQxN2E2ZGIwMDYwNzVkMGZkNDZiNWE5
14
- ZDE3YmM4OTBhMzI0ZmFjOTM0ODVhMmUwZDJkNWY3OWRlYmJkZjUwMzczMzg0
15
- YjZiZTViM2ZmNDc2ZGEyY2NmMmQ1ZTQyMmU4M2NhZjAyMmRhN2Y=
13
+ NWFkZGFkNjY5OWE4NmViZWEzOWNhNzllNjZiZTg1NzI2YmFjNzRmOTYyNGE0
14
+ OTM4ZDA0YTc1ZmM5MzdmYzdlY2I0YzMwOTVhNDE0YTBjYjk5YzM0MjVhNGEw
15
+ NTUxOWIyOTkzOGExNDliZjY1ZTI0NTUyYzVlYjlkNTY3ZWE5Yzg=
@@ -1,4 +1,10 @@
1
1
 
2
+ 0.1.27 / 2013-07-10
3
+ ===================
4
+
5
+ * Fixes AR's notification by changing the ordering
6
+ * Update the ActiveRecord log subscriber to work with AR 4.0.0
7
+
2
8
  0.1.26 / 2013-07-10
3
9
  ===================
4
10
 
@@ -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
- hash[col.name] = v
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, 's']
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
 
@@ -1,3 +1,3 @@
1
1
  module Lines
2
- VERSION = "0.1.26"
2
+ VERSION = "0.1.27"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lines
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.26
4
+ version: 0.1.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Pfenniger