salestation 3.2.1 → 3.2.2
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.
- checksums.yaml +4 -4
- data/lib/salestation/web/request_logger.rb +10 -18
- data/salestation.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2ce01f52dfc5a837a48d3ce6923fb435edc830262506666a368c93f96e6ad83
|
4
|
+
data.tar.gz: 899d05be06cafb0164abafcce4958f1fea6abe48b0ea118c6b44206be1dbd865
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0109c1a56a529c85a8f252425524d6d4012c18e5da7fb729c070c2de8c3a716a09f5059bdd7201f47d977c0fa3ee8e060617a8ebafefd00c1d698d90afdcee72'
|
7
|
+
data.tar.gz: c83118eac0a175287c7ce9af30c225aa02bff963b8ec7360a108297a9c076e06916454cb8949ea2ff8cb1da4ee03ff979831f51a5fcc0246376dea3e23a91e3f
|
@@ -1,11 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'json'
|
4
|
-
|
5
3
|
module Salestation
|
6
4
|
class Web < Module
|
7
5
|
class RequestLogger
|
8
|
-
|
6
|
+
DURATION_PRECISION = 6
|
9
7
|
REMOTE_ADDR = 'REMOTE_ADDR'
|
10
8
|
REQUEST_URI = 'REQUEST_URI'
|
11
9
|
REQUEST_METHOD = 'REQUEST_METHOD'
|
@@ -14,7 +12,6 @@ module Salestation
|
|
14
12
|
HTTP_USER_AGENT = 'HTTP_USER_AGENT'
|
15
13
|
HTTP_ACCEPT = 'HTTP_ACCEPT'
|
16
14
|
SERVER_NAME = 'SERVER_NAME'
|
17
|
-
JSON_CONTENT_TYPE = 'application/json'
|
18
15
|
|
19
16
|
def initialize(app, logger, log_response_body: false)
|
20
17
|
@app = app
|
@@ -23,7 +20,7 @@ module Salestation
|
|
23
20
|
end
|
24
21
|
|
25
22
|
def call(env)
|
26
|
-
began_at =
|
23
|
+
began_at = system_monotonic_time
|
27
24
|
|
28
25
|
@app.call(env).tap do |status, headers, body|
|
29
26
|
type = status >= 500 ? :error : :info
|
@@ -44,30 +41,25 @@ module Salestation
|
|
44
41
|
http_accept: env[HTTP_ACCEPT],
|
45
42
|
server_name: env[SERVER_NAME],
|
46
43
|
status: status,
|
47
|
-
duration:
|
44
|
+
duration: duration(from: began_at),
|
48
45
|
headers: headers
|
49
46
|
}
|
50
47
|
|
51
48
|
if status >= 400
|
52
|
-
log[:error] =
|
49
|
+
log[:error] = body.join
|
53
50
|
elsif @log_response_body
|
54
|
-
log[:body] =
|
51
|
+
log[:body] = body.join
|
55
52
|
end
|
56
53
|
|
57
54
|
log
|
58
55
|
end
|
59
56
|
|
60
|
-
def
|
61
|
-
|
62
|
-
|
57
|
+
def duration(from:)
|
58
|
+
(system_monotonic_time - from).round(DURATION_PRECISION)
|
59
|
+
end
|
63
60
|
|
64
|
-
|
65
|
-
|
66
|
-
else
|
67
|
-
JSON.parse(body.join)
|
68
|
-
end
|
69
|
-
rescue Exception
|
70
|
-
{error: 'Failed to parse response body'}
|
61
|
+
def system_monotonic_time
|
62
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
71
63
|
end
|
72
64
|
end
|
73
65
|
end
|
data/salestation.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: salestation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SaleMove TechMovers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|