leviathan-rails 0.0.2.alpha → 0.0.3.alpha

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.
Files changed (2) hide show
  1. data/lib/leviathan-rails.rb +9 -0
  2. metadata +1 -1
@@ -7,6 +7,13 @@ require 'activesupport_notifications_backport'
7
7
  APP_ROOT = File.dirname(__FILE__)
8
8
 
9
9
  module Leviathan
10
+ class SqlLogSubscriber < ActiveSupport::LogSubscriber
11
+ def sql(event)
12
+ message = event.payload,to_msgpack
13
+ UDPSocket.new.send message, 0, Leviathon::connection[:port], Leviathan::connection[:port]
14
+ end
15
+ end
16
+
10
17
  def self.connection
11
18
  @connection
12
19
  end
@@ -25,6 +32,8 @@ module Leviathan
25
32
  Leviathan::notify(connection, args)
26
33
  end
27
34
  end
35
+
36
+ SqlLogSubscriber.attach_to :active_record
28
37
  end
29
38
 
30
39
  def self.notify(connection, args)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leviathan-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2.alpha
4
+ version: 0.0.3.alpha
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors: