resurfaceio-logger 1.8.0 → 1.8.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3be2e4cca1408ec107b7311ee3719b89ba23bd0
|
4
|
+
data.tar.gz: 98406ab661b3dbfb74e3f62b231c288363e444b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90a62d981f55556545de8350709e967206f0c2f706afa7fdf988dfb435219c57d235b6ee212761249ddeb1c19c95de18336c2c0ab2dd1d010e7de0528017b04d
|
7
|
+
data.tar.gz: 5f94610eb8077981971636bca25cbe322773a3241fb03b2b6845ab4a84e3db9479535dff239a81dc506cff76d4d1bd525ddea030f46e84d9fabdbc9192391f16
|
@@ -4,12 +4,15 @@
|
|
4
4
|
require 'uri'
|
5
5
|
require 'net/http'
|
6
6
|
require 'net/https'
|
7
|
+
require 'zlib'
|
7
8
|
require 'resurfaceio/usage_loggers'
|
8
9
|
|
9
10
|
class BaseLogger
|
10
11
|
|
11
|
-
def initialize(agent, options={})
|
12
|
+
def initialize(agent, options = {})
|
12
13
|
@agent = agent
|
14
|
+
@skip_compression = false
|
15
|
+
@skip_submission = false
|
13
16
|
@version = BaseLogger.version_lookup
|
14
17
|
|
15
18
|
# set options in priority order
|
@@ -65,8 +68,24 @@ class BaseLogger
|
|
65
68
|
@enabled && UsageLoggers.enabled?
|
66
69
|
end
|
67
70
|
|
71
|
+
def skip_compression?
|
72
|
+
@skip_compression
|
73
|
+
end
|
74
|
+
|
75
|
+
def skip_compression=(value)
|
76
|
+
@skip_compression = value
|
77
|
+
end
|
78
|
+
|
79
|
+
def skip_submission?
|
80
|
+
@skip_submission
|
81
|
+
end
|
82
|
+
|
83
|
+
def skip_submission=(value)
|
84
|
+
@skip_submission = value
|
85
|
+
end
|
86
|
+
|
68
87
|
def submit(json)
|
69
|
-
if !enabled?
|
88
|
+
if @skip_submission || !enabled?
|
70
89
|
true
|
71
90
|
elsif @queue
|
72
91
|
@queue << json
|
@@ -77,7 +96,12 @@ class BaseLogger
|
|
77
96
|
@url_connection ||= Net::HTTP.new(@url_parsed.host, @url_parsed.port)
|
78
97
|
@url_connection.use_ssl = @url.include?('https')
|
79
98
|
request = Net::HTTP::Post.new(@url_parsed.path)
|
80
|
-
|
99
|
+
if @skip_compression
|
100
|
+
request.body = json
|
101
|
+
else
|
102
|
+
request.add_field('Content-Encoding', 'deflated')
|
103
|
+
request.body = Zlib::Deflate.deflate(json)
|
104
|
+
end
|
81
105
|
response = @url_connection.request(request)
|
82
106
|
response.code.to_i == 204
|
83
107
|
rescue SocketError
|
@@ -11,6 +11,10 @@ class HttpLoggerForRack # http://rack.rubyforge.org/doc/SPEC.html
|
|
11
11
|
@logger = HttpLogger.new(options)
|
12
12
|
end
|
13
13
|
|
14
|
+
def logger
|
15
|
+
@logger
|
16
|
+
end
|
17
|
+
|
14
18
|
def call(env)
|
15
19
|
status, headers, body = @app.call(env)
|
16
20
|
if @logger.enabled? && (status < 300 || status == 302)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resurfaceio-logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RobDickinson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|