pg-connection-general_log 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 136b9087c2627d7e15e8b9628d481a2226998a91
4
- data.tar.gz: da67bac81d731c05daa133e8084d7ae4b3523ad6
3
+ metadata.gz: 7825d72bab21243fca9b81dd2f6b3d5f9514e346
4
+ data.tar.gz: f31e2f859992fac1039450a8f42f1b22e5c7b91c
5
5
  SHA512:
6
- metadata.gz: 472166a3d5f5dcf0f0e641c19a9e35b5fc264a44f3d8229d58c61859ced3280496935be28c8603ada34a7d588e2fb31114547be57bb2e599d8fd1870673ace63
7
- data.tar.gz: 5285b8473499fc7928741ada338487835dbb7b561e40f3f8debb1db425f661e958d016970e3aede1ca8ec9bb3d7a482cfb36c60586807de07f757f20e04ff5e0
6
+ metadata.gz: caa984d618acbbd775e7fb840662c16aa4403305aec814e0cbefecce23097d7c4abdec7439aece1c1231604d91a557687d6834214d8a7316ca1a94f03929ab45
7
+ data.tar.gz: 2490d74401305db28a85a78c6b24cac8305c369630f5d7a4a37bffcdd8dbab55c4cd4ace7ee2eb861057ee61445c029438b830c6266a442513cb9856b2a6a63d
@@ -12,7 +12,16 @@ module PG
12
12
  module GeneralLog
13
13
  class << self
14
14
  def general_log
15
- Thread.current[:general_log] ||= Logger.new
15
+ Thread.current[:general_log] ||= {}
16
+ Thread.current[:general_log][Thread.current[:request_id]] ||= Logger.new
17
+ end
18
+
19
+ def general_log_with_request_id(request_id)
20
+ Thread.current.dig(:general_log, request_id)
21
+ end
22
+
23
+ def delete_general_log(request_id)
24
+ Thread.current[:general_log]&.delete(request_id)
16
25
  end
17
26
 
18
27
  def prepend_module
@@ -16,13 +16,17 @@ module PG
16
16
  end
17
17
 
18
18
  def call(env)
19
- GeneralLog.general_log.clear if Middleware.enabled
19
+ if Middleware.enabled
20
+ request = Rack::Request.new env
21
+ request_id = request.uuid
22
+ Thread.current[:request_id] = request_id
23
+ end
20
24
  @app.call(env)
21
25
  ensure
22
26
  if Middleware.enabled
23
- request = Rack::Request.new env
24
- puts request.path
25
- GeneralLog.general_log.writefile(request)
27
+ GeneralLog.general_log_with_request_id(request_id).writefile(request)
28
+ GeneralLog.delete_general_log(request_id)
29
+ Thread.current[:request_id] = nil
26
30
  end
27
31
  end
28
32
  end
@@ -1,7 +1,7 @@
1
1
  module PG
2
2
  class Connection
3
3
  module GeneralLog
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.3"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg-connection-general_log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - abcang