pg-connection-general_log 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -7
- data/Rakefile +4 -0
- data/example/config.ru +6 -0
- data/example/test.rb +18 -3
- data/lib/pg/connection/general_log.rb +11 -76
- data/lib/pg/connection/general_log/connection_ext.rb +49 -0
- data/lib/pg/connection/general_log/log.rb +19 -0
- data/lib/pg/connection/general_log/logger.rb +25 -0
- data/lib/pg/connection/general_log/middleware.rb +31 -0
- data/lib/pg/connection/general_log/version.rb +4 -2
- data/lib/pg/connection/general_log_test.rb +32 -30
- data/pg-connection-general_logs.gemspec +3 -3
- metadata +21 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 136b9087c2627d7e15e8b9628d481a2226998a91
|
4
|
+
data.tar.gz: da67bac81d731c05daa133e8084d7ae4b3523ad6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 472166a3d5f5dcf0f0e641c19a9e35b5fc264a44f3d8229d58c61859ced3280496935be28c8603ada34a7d588e2fb31114547be57bb2e599d8fd1870673ace63
|
7
|
+
data.tar.gz: 5285b8473499fc7928741ada338487835dbb7b561e40f3f8debb1db425f661e958d016970e3aede1ca8ec9bb3d7a482cfb36c60586807de07f757f20e04ff5e0
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PG:Connection::GeneralLog
|
2
2
|
===
|
3
3
|
|
4
|
-
[![Build Status](https://travis-ci.org/abcang/pg-connection-general_log.svg?branch=
|
4
|
+
[![Build Status](https://travis-ci.org/abcang/pg-connection-general_log.svg?branch=master)](https://travis-ci.org/abcang/pg-connection-general_log)
|
5
5
|
|
6
6
|
A monkey patch for pg.
|
7
7
|
Stock all general logs.
|
@@ -16,7 +16,7 @@ require "pg/connection/general_log"
|
|
16
16
|
client = PG::Connection.new(config)
|
17
17
|
client.query("SELECT * FROM users LIMIT 1")
|
18
18
|
|
19
|
-
p
|
19
|
+
p PG::Connection::GeneralLog.general_log #=>
|
20
20
|
# [
|
21
21
|
# #<struct PG::Connection::GeneralLog::Log
|
22
22
|
# sql="SELECT * FROM users LIMIT 1",
|
@@ -30,6 +30,16 @@ p client.general_log #=>
|
|
30
30
|
|
31
31
|
### sinatra
|
32
32
|
|
33
|
+
config.ru:
|
34
|
+
```ruby
|
35
|
+
require_relative './test'
|
36
|
+
|
37
|
+
require 'pg/connection/general_log'
|
38
|
+
|
39
|
+
use PG::Connection::GeneralLog::Middleware, enabled: true, backtrace: true, path: '/tmp/general_log'
|
40
|
+
run Sinatra::Application
|
41
|
+
```
|
42
|
+
|
33
43
|
test.rb:
|
34
44
|
```ruby
|
35
45
|
require 'sinatra'
|
@@ -50,13 +60,9 @@ get '/' do
|
|
50
60
|
db.exec_prepared('select', ['bar'])
|
51
61
|
db.exec_prepared('select', ['foo'])
|
52
62
|
end
|
53
|
-
|
54
|
-
after do
|
55
|
-
db.general_log.writefile(path: '/tmp/sql.log', req: request, backtrace: true)
|
56
|
-
end
|
57
63
|
```
|
58
64
|
|
59
|
-
/tmp/
|
65
|
+
/tmp/general_log/2017-11-19.log:
|
60
66
|
```
|
61
67
|
REQUEST GET / 4
|
62
68
|
SQL (0000.89ms) SELECT * FROM users WHERE name = 'hoge' [] /path/to/test.rb:12:in `block in <main>'
|
@@ -78,6 +84,18 @@ And then execute:
|
|
78
84
|
$ bundle
|
79
85
|
|
80
86
|
|
87
|
+
## Test
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
$ bundle exec rake
|
91
|
+
```
|
92
|
+
|
93
|
+
## example server
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
$ bundle exec rake example
|
97
|
+
```
|
98
|
+
|
81
99
|
## License
|
82
100
|
|
83
101
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
data/example/config.ru
ADDED
data/example/test.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'sinatra'
|
2
2
|
require 'pg'
|
3
|
-
require 'pg/connection/general_log'
|
4
3
|
|
5
4
|
helpers do
|
6
5
|
def db
|
@@ -11,6 +10,13 @@ helpers do
|
|
11
10
|
)
|
12
11
|
end
|
13
12
|
|
13
|
+
def pg
|
14
|
+
PG.connect(
|
15
|
+
host: '127.0.0.1',
|
16
|
+
user: 'postgres'
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
14
20
|
def init
|
15
21
|
db.exec('DROP TABLE IF EXISTS users')
|
16
22
|
db.exec(<<-SQL)
|
@@ -37,12 +43,21 @@ get '/' do
|
|
37
43
|
db.prepare('select', 'SELECT * FROM users WHERE name = $1')
|
38
44
|
db.exec_prepared('select', ['bar'])
|
39
45
|
db.exec_prepared('select', ['foo'])
|
46
|
+
|
47
|
+
'ok'
|
40
48
|
end
|
41
49
|
|
42
50
|
get '/init' do
|
51
|
+
pg.exec('DROP DATABASE IF EXISTS pg_connection_general_log_test')
|
52
|
+
pg.exec('CREATE DATABASE pg_connection_general_log_test')
|
53
|
+
|
43
54
|
init
|
55
|
+
|
56
|
+
'init'
|
44
57
|
end
|
45
58
|
|
46
|
-
|
47
|
-
|
59
|
+
get '/down' do
|
60
|
+
pg.exec('DROP DATABASE IF EXISTS pg_connection_general_log_test')
|
61
|
+
|
62
|
+
'down'
|
48
63
|
end
|
@@ -1,89 +1,24 @@
|
|
1
1
|
require 'pg'
|
2
2
|
require 'benchmark'
|
3
3
|
|
4
|
+
require 'pg/connection/general_log/connection_ext'
|
5
|
+
require 'pg/connection/general_log/log'
|
6
|
+
require 'pg/connection/general_log/logger'
|
7
|
+
require 'pg/connection/general_log/middleware'
|
8
|
+
require 'pg/connection/general_log/version'
|
9
|
+
|
4
10
|
module PG
|
5
11
|
class Connection
|
6
12
|
module GeneralLog
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def format(use_bt = false)
|
11
|
-
ret = [
|
12
|
-
'SQL',
|
13
|
-
'(%07.2fms)' % (time * 1000),
|
14
|
-
sql.gsub(/[\r\n]/, ' ').gsub(/ +/, ' ').strip,
|
15
|
-
args.to_s
|
16
|
-
]
|
17
|
-
ret << backtrace[0] if use_bt
|
18
|
-
|
19
|
-
ret.join("\t")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class Logger < Array
|
24
|
-
def writefile(path: '/tmp/sql.log', req: nil, backtrace: false)
|
25
|
-
File.open(path, 'a') do |file|
|
26
|
-
if req
|
27
|
-
file.puts "REQUEST\t#{req.request_method}\t#{req.path}\t#{self.length}"
|
28
|
-
end
|
29
|
-
|
30
|
-
file.puts self.map { |log| log.format(backtrace) }.join("\n")
|
31
|
-
file.puts ''
|
32
|
-
end
|
33
|
-
self.clear
|
13
|
+
class << self
|
14
|
+
def general_log
|
15
|
+
Thread.current[:general_log] ||= Logger.new
|
34
16
|
end
|
35
17
|
|
36
|
-
def
|
37
|
-
|
18
|
+
def prepend_module
|
19
|
+
PG::Connection.send(:prepend, ConnectionExt)
|
38
20
|
end
|
39
21
|
end
|
40
|
-
|
41
|
-
attr_accessor :general_log
|
42
|
-
|
43
|
-
def initialize(opts = {})
|
44
|
-
@general_log = Logger.new
|
45
|
-
@stmt_map = {}
|
46
|
-
super
|
47
|
-
end
|
48
|
-
|
49
|
-
def exec(sql)
|
50
|
-
ret = nil
|
51
|
-
time = Benchmark.realtime do
|
52
|
-
ret = super
|
53
|
-
end
|
54
|
-
@general_log.push(sql, [], caller_locations, time)
|
55
|
-
ret
|
56
|
-
end
|
57
|
-
|
58
|
-
def exec_params(*args)
|
59
|
-
sql, params = args
|
60
|
-
ret = nil
|
61
|
-
time = Benchmark.realtime do
|
62
|
-
ret = super
|
63
|
-
end
|
64
|
-
@general_log.push(sql, params, caller_locations, time)
|
65
|
-
ret
|
66
|
-
end
|
67
|
-
|
68
|
-
def prepare(*args)
|
69
|
-
stmt_name, sql = args
|
70
|
-
@stmt_map[stmt_name] = sql
|
71
|
-
super
|
72
|
-
end
|
73
|
-
|
74
|
-
def exec_prepared(*args)
|
75
|
-
stmt_name, params = args
|
76
|
-
sql = @stmt_map[stmt_name]
|
77
|
-
|
78
|
-
ret = nil
|
79
|
-
time = Benchmark.realtime do
|
80
|
-
ret = super
|
81
|
-
end
|
82
|
-
@general_log.push(sql, params, caller_locations, time)
|
83
|
-
ret
|
84
|
-
end
|
85
22
|
end
|
86
|
-
|
87
|
-
prepend GeneralLog
|
88
23
|
end
|
89
24
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module PG
|
2
|
+
class Connection
|
3
|
+
module GeneralLog
|
4
|
+
module ConnectionExt
|
5
|
+
def initialize(*)
|
6
|
+
@stmt_map = {}
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def exec(sql)
|
11
|
+
ret = nil
|
12
|
+
time = Benchmark.realtime do
|
13
|
+
ret = super
|
14
|
+
end
|
15
|
+
GeneralLog.general_log.push(sql, [], caller_locations, time)
|
16
|
+
ret
|
17
|
+
end
|
18
|
+
|
19
|
+
def exec_params(*args)
|
20
|
+
sql, params = args
|
21
|
+
ret = nil
|
22
|
+
time = Benchmark.realtime do
|
23
|
+
ret = super
|
24
|
+
end
|
25
|
+
GeneralLog.general_log.push(sql, params, caller_locations, time)
|
26
|
+
ret
|
27
|
+
end
|
28
|
+
|
29
|
+
def prepare(*args)
|
30
|
+
stmt_name, sql = args
|
31
|
+
@stmt_map[stmt_name] = sql
|
32
|
+
super
|
33
|
+
end
|
34
|
+
|
35
|
+
def exec_prepared(*args)
|
36
|
+
stmt_name, params = args
|
37
|
+
sql = @stmt_map[stmt_name]
|
38
|
+
|
39
|
+
ret = nil
|
40
|
+
time = Benchmark.realtime do
|
41
|
+
ret = super
|
42
|
+
end
|
43
|
+
GeneralLog.general_log.push(sql, params, caller_locations, time)
|
44
|
+
ret
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module PG
|
2
|
+
class Connection
|
3
|
+
module GeneralLog
|
4
|
+
class Log < Struct.new(:sql, :args, :backtrace, :time)
|
5
|
+
def format(use_bt = false)
|
6
|
+
ret = [
|
7
|
+
'SQL',
|
8
|
+
'(%07.2fms)' % (time * 1000),
|
9
|
+
sql.gsub(/[\r\n]/, ' ').gsub(/ +/, ' ').strip,
|
10
|
+
args.to_s
|
11
|
+
]
|
12
|
+
ret << backtrace[0] if use_bt
|
13
|
+
|
14
|
+
ret.join("\t")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
module PG
|
5
|
+
class Connection
|
6
|
+
module GeneralLog
|
7
|
+
class Logger < Array
|
8
|
+
def writefile(req)
|
9
|
+
FileUtils.mkdir_p(Middleware.path)
|
10
|
+
File.open(File.join(Middleware.path, "#{Date.today}.txt"), 'a') do |file|
|
11
|
+
if req
|
12
|
+
file.puts "REQUEST\t#{req.request_method}\t#{req.fullpath}\t#{self.length}"
|
13
|
+
end
|
14
|
+
|
15
|
+
file.puts self.map { |log| log.format(Middleware.backtrace) }.join("\n") + "\n\n"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def push(sql, args, backtrace, time)
|
20
|
+
super(Log.new(sql, args, backtrace, time))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module PG
|
2
|
+
class Connection
|
3
|
+
module GeneralLog
|
4
|
+
class Middleware
|
5
|
+
class << self
|
6
|
+
attr_accessor :enabled, :path, :backtrace
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(app, options = {})
|
10
|
+
@app = app
|
11
|
+
Middleware.enabled = options[:enabled]
|
12
|
+
Middleware.path = options[:path] || '/tmp/general_log'
|
13
|
+
Middleware.backtrace = options[:backtrace] || false
|
14
|
+
|
15
|
+
GeneralLog.prepend_module if Middleware.enabled
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(env)
|
19
|
+
GeneralLog.general_log.clear if Middleware.enabled
|
20
|
+
@app.call(env)
|
21
|
+
ensure
|
22
|
+
if Middleware.enabled
|
23
|
+
request = Rack::Request.new env
|
24
|
+
puts request.path
|
25
|
+
GeneralLog.general_log.writefile(request)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -2,6 +2,7 @@ require 'pg/connection/general_log'
|
|
2
2
|
|
3
3
|
module PGConnectionGeneralLogTest
|
4
4
|
def test_main(m)
|
5
|
+
PG::Connection::GeneralLog.prepend_module
|
5
6
|
client = PG.connect(
|
6
7
|
host: '127.0.0.1',
|
7
8
|
user: 'postgres'
|
@@ -14,6 +15,7 @@ module PGConnectionGeneralLogTest
|
|
14
15
|
user: 'postgres',
|
15
16
|
dbname: 'pg_connection_general_log_test'
|
16
17
|
)
|
18
|
+
PG::Connection::GeneralLog.general_log.clear
|
17
19
|
exit m.run
|
18
20
|
|
19
21
|
client.exec('DROP DATABASE IF EXISTS pg_connection_general_log_test')
|
@@ -35,15 +37,15 @@ module PGConnectionGeneralLogTest
|
|
35
37
|
('bar', 'barr')
|
36
38
|
;
|
37
39
|
SQL
|
38
|
-
|
40
|
+
PG::Connection::GeneralLog.general_log.clear
|
39
41
|
end
|
40
42
|
|
41
43
|
def test_init(t)
|
42
|
-
unless
|
43
|
-
t.error("initial value expect Array class got #{
|
44
|
+
unless PG::Connection::GeneralLog.general_log.is_a?(Array)
|
45
|
+
t.error("initial value expect Array class got #{PG::Connection::GeneralLog.general_log.class}")
|
44
46
|
end
|
45
|
-
unless
|
46
|
-
t.error("initial value expect [] got #{
|
47
|
+
unless PG::Connection::GeneralLog.general_log.empty?
|
48
|
+
t.error("initial value expect [] got #{PG::Connection::GeneralLog.general_log}")
|
47
49
|
end
|
48
50
|
end
|
49
51
|
|
@@ -53,21 +55,21 @@ module PGConnectionGeneralLogTest
|
|
53
55
|
@client.exec("SELECT * FROM users WHERE name = '#{'bar'}'")
|
54
56
|
@client.exec("SELECT * FROM users WHERE name = '#{'foo'}'")
|
55
57
|
|
56
|
-
if
|
57
|
-
t.error("expect log length 3 got #{
|
58
|
+
if PG::Connection::GeneralLog.general_log.length != 3
|
59
|
+
t.error("expect log length 3 got #{PG::Connection::GeneralLog.general_log.length}")
|
58
60
|
end
|
59
|
-
if
|
60
|
-
t.error("expect all collection item is instance of PG::Connection::GeneralLog::Log got #{
|
61
|
+
if PG::Connection::GeneralLog.general_log.any?{|log| !log.is_a?(PG::Connection::GeneralLog::Log)}
|
62
|
+
t.error("expect all collection item is instance of PG::Connection::GeneralLog::Log got #{PG::Connection::GeneralLog.general_log.map(&:class).uniq}")
|
61
63
|
end
|
62
64
|
expect = { 'id' => '1', 'name' => 'hoge', 'password' => 'cheap-pass' }
|
63
65
|
if ret != expect
|
64
66
|
t.error("expect exec output not change from #{expect} got #{ret}")
|
65
67
|
end
|
66
|
-
unless
|
67
|
-
t.error("expect log format not correct got `#{
|
68
|
+
unless PG::Connection::GeneralLog.general_log.first.format =~ /^SQL\t\(\d+\.\d+ms\)\tSELECT \* FROM users WHERE name = 'hoge'\t\[\]$/
|
69
|
+
t.error("expect log format not correct got `#{PG::Connection::GeneralLog.general_log.first.format}`")
|
68
70
|
end
|
69
|
-
unless
|
70
|
-
t.error("expect log format not correct got `#{
|
71
|
+
unless PG::Connection::GeneralLog.general_log.first.format(true) =~ /^SQL\t\(\d+\.\d+ms\)\tSELECT \* FROM users WHERE name = 'hoge'\t\[\].+in `test_values'$/
|
72
|
+
t.error("expect log format not correct got `#{PG::Connection::GeneralLog.general_log.first.format(true)}`")
|
71
73
|
end
|
72
74
|
end
|
73
75
|
|
@@ -77,21 +79,21 @@ module PGConnectionGeneralLogTest
|
|
77
79
|
@client.exec_params('SELECT * FROM users WHERE name = $1', ['bar'])
|
78
80
|
@client.exec_params('SELECT * FROM users WHERE name = $1', ['foo'])
|
79
81
|
|
80
|
-
if
|
81
|
-
t.error("expect log length 3 got #{
|
82
|
+
if PG::Connection::GeneralLog.general_log.length != 3
|
83
|
+
t.error("expect log length 3 got #{PG::Connection::GeneralLog.general_log.length}")
|
82
84
|
end
|
83
|
-
if
|
84
|
-
t.error("expect all collection item is instance of PG::Connection::GeneralLog::Log got #{
|
85
|
+
if PG::Connection::GeneralLog.general_log.any?{|log| !log.is_a?(PG::Connection::GeneralLog::Log)}
|
86
|
+
t.error("expect all collection item is instance of PG::Connection::GeneralLog::Log got #{PG::Connection::GeneralLog.general_log.map(&:class).uniq}")
|
85
87
|
end
|
86
88
|
expect = { 'id' => '1', 'name' => 'hoge', 'password' => 'cheap-pass' }
|
87
89
|
if ret != expect
|
88
90
|
t.error("expect exec output not change from #{expect} got #{ret}")
|
89
91
|
end
|
90
|
-
unless
|
91
|
-
t.error("expect log format not correct got `#{
|
92
|
+
unless PG::Connection::GeneralLog.general_log.first.format =~ /^SQL\t\(\d+\.\d+ms\)\tSELECT \* FROM users WHERE name = \$1\t\["hoge"\]$/
|
93
|
+
t.error("expect log format not correct got `#{PG::Connection::GeneralLog.general_log.first.format}`")
|
92
94
|
end
|
93
|
-
unless
|
94
|
-
t.error("expect log format not correct got `#{
|
95
|
+
unless PG::Connection::GeneralLog.general_log.first.format(true) =~ /^SQL\t\(\d+\.\d+ms\)\tSELECT \* FROM users WHERE name = \$1\t\["hoge"\].+in `test_params_values'$/
|
96
|
+
t.error("expect log format not correct got `#{PG::Connection::GeneralLog.general_log.first.format(true)}`")
|
95
97
|
end
|
96
98
|
end
|
97
99
|
|
@@ -102,21 +104,21 @@ module PGConnectionGeneralLogTest
|
|
102
104
|
@client.exec_prepared('select', ['bar'])
|
103
105
|
@client.exec_prepared('select', ['foo'])
|
104
106
|
|
105
|
-
if
|
106
|
-
t.error("expect log length 3 got #{
|
107
|
+
if PG::Connection::GeneralLog.general_log.length != 3
|
108
|
+
t.error("expect log length 3 got #{PG::Connection::GeneralLog.general_log.length}")
|
107
109
|
end
|
108
|
-
if
|
109
|
-
t.error("expect all collection item is instance of PG::Connection::GeneralLog::Log got #{
|
110
|
+
if PG::Connection::GeneralLog.general_log.any?{|log| !log.is_a?(PG::Connection::GeneralLog::Log)}
|
111
|
+
t.error("expect all collection item is instance of PG::Connection::GeneralLog::Log got #{PG::Connection::GeneralLog.general_log.map(&:class).uniq}")
|
110
112
|
end
|
111
113
|
expect = { 'id' => '1', 'name' => 'hoge', 'password' => 'cheap-pass' }
|
112
114
|
if ret != expect
|
113
115
|
t.error("expect exec output not change from #{expect} got #{ret}")
|
114
116
|
end
|
115
|
-
unless
|
116
|
-
t.error("expect log format not correct got `#{
|
117
|
+
unless PG::Connection::GeneralLog.general_log.first.format =~ /^SQL\t\(\d+\.\d+ms\)\tSELECT \* FROM users WHERE name = \$1\t\["hoge"\]$/
|
118
|
+
t.error("expect log format not correct got `#{PG::Connection::GeneralLog.general_log.first.format}`")
|
117
119
|
end
|
118
|
-
unless
|
119
|
-
t.error("expect log format not correct got `#{
|
120
|
+
unless PG::Connection::GeneralLog.general_log.first.format(true) =~ /^SQL\t\(\d+\.\d+ms\)\tSELECT \* FROM users WHERE name = \$1\t\["hoge"\].+in `test_prepare_values'$/
|
121
|
+
t.error("expect log format not correct got `#{PG::Connection::GeneralLog.general_log.first.format(true)}`")
|
120
122
|
end
|
121
123
|
end
|
122
124
|
|
@@ -134,7 +136,7 @@ module PGConnectionGeneralLogTest
|
|
134
136
|
@client.prepare('select2', 'SELECT * FROM users WHERE name = $1')
|
135
137
|
@client.exec_prepared('select2', ['bar'])
|
136
138
|
@client.exec_prepared('select2', ['foo'])
|
137
|
-
puts
|
139
|
+
puts PG::Connection::GeneralLog.general_log.map { |log| [log.sql, log.args.to_s, log.backtrace.find{|c| %r{/gems/} !~ c.to_s}.to_s.gsub(/.*?:/, '')].join(' ') }
|
138
140
|
# Output:
|
139
141
|
# SELECT * FROM users WHERE name = 'hoge' [] in `example_general_log'
|
140
142
|
# SELECT * FROM users WHERE name = $1 ["hoge"] in `example_general_log'
|
@@ -1,11 +1,10 @@
|
|
1
1
|
lib = File.expand_path('../lib', __FILE__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
|
4
|
-
version = Regexp.last_match(1)
|
3
|
+
require 'pg/connection/general_log/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
6
|
spec.name = 'pg-connection-general_log'
|
8
|
-
spec.version =
|
7
|
+
spec.version = PG::Connection::GeneralLog::VERSION
|
9
8
|
spec.authors = ['abcang']
|
10
9
|
spec.email = ['abcang1015@gmail.com']
|
11
10
|
|
@@ -21,4 +20,5 @@ Gem::Specification.new do |spec|
|
|
21
20
|
spec.add_development_dependency 'bundler', '~> 1.15'
|
22
21
|
spec.add_development_dependency 'rake', '~> 12.2'
|
23
22
|
spec.add_development_dependency 'rgot'
|
23
|
+
spec.add_development_dependency 'sinatra'
|
24
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg-connection-general_log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- abcang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sinatra
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: Simple stocker general log for pg gem.
|
70
84
|
email:
|
71
85
|
- abcang1015@gmail.com
|
@@ -79,8 +93,13 @@ files:
|
|
79
93
|
- LICENSE.txt
|
80
94
|
- README.md
|
81
95
|
- Rakefile
|
96
|
+
- example/config.ru
|
82
97
|
- example/test.rb
|
83
98
|
- lib/pg/connection/general_log.rb
|
99
|
+
- lib/pg/connection/general_log/connection_ext.rb
|
100
|
+
- lib/pg/connection/general_log/log.rb
|
101
|
+
- lib/pg/connection/general_log/logger.rb
|
102
|
+
- lib/pg/connection/general_log/middleware.rb
|
84
103
|
- lib/pg/connection/general_log/version.rb
|
85
104
|
- lib/pg/connection/general_log_test.rb
|
86
105
|
- pg-connection-general_logs.gemspec
|