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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7825d72bab21243fca9b81dd2f6b3d5f9514e346
|
4
|
+
data.tar.gz: f31e2f859992fac1039450a8f42f1b22e5c7b91c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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] ||=
|
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
|
-
|
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
|
24
|
-
|
25
|
-
|
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
|