http_streaming_client 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/lib/http_streaming_client/client.rb +4 -3
- data/lib/http_streaming_client/custom_logger.rb +21 -2
- data/lib/http_streaming_client/version.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73350e7f53d3119b0ba665d5228b6735b550bc13
|
4
|
+
data.tar.gz: 30237aa995e8bf299eb04c42e0a676de2d103360
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86dcb970868729a1c292bddec3e35d48b7e50cebeaa62dfceea411ec056c5202cb8b517da0ecb3094b1a2d519a667b7299cfa772464c200c1a163205209fdb3d
|
7
|
+
data.tar.gz: 645188e2ad4aa19a82382d330a56a7072b6190987ebcdb94b10faad246f0bcb952725325437ee5b4c66104c11111b3e993ad28c3896f03f6a6a515f894119e8a
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
http_streaming_client 0.9.5 (05.23.2014)
|
2
|
+
========================================
|
3
|
+
* Added logging tag functions to add tags to log messages for multi-threaded environments
|
4
|
+
|
1
5
|
http_streaming_client 0.9.4 (05.22.2014)
|
2
6
|
========================================
|
3
7
|
* Fixed bug with reconnect management and lazy authorization header generation
|
@@ -134,9 +134,9 @@ module HttpStreamingClient
|
|
134
134
|
|
135
135
|
if !@options_factory.nil? then
|
136
136
|
if @options_factory.respond_to? "get_options" then
|
137
|
-
logger.
|
137
|
+
logger.debug("Client::request:options_factory detected")
|
138
138
|
generated_options = @options_factory.get_options
|
139
|
-
logger.
|
139
|
+
logger.debug("Client::request:options_factory:#{generated_options}")
|
140
140
|
opts.merge!(generated_options || {})
|
141
141
|
else
|
142
142
|
logger.warn("Client::request:options_factory detected, but does not respond to get_options(). Ignoring.")
|
@@ -172,6 +172,7 @@ module HttpStreamingClient
|
|
172
172
|
logger.debug "request headers: #{headers}"
|
173
173
|
|
174
174
|
socket = initialize_socket(uri, opts)
|
175
|
+
logger.info("Connected to #{uri}")
|
175
176
|
|
176
177
|
request = "#{method} #{uri.path}#{uri.query ? "?"+uri.query : nil} HTTP/1.1\r\n"
|
177
178
|
request << "Host: #{uri.host}\r\n"
|
@@ -383,7 +384,7 @@ module HttpStreamingClient
|
|
383
384
|
if @reconnect_requested then
|
384
385
|
logger.info "Connection closed. Reconnect requested. Trying..."
|
385
386
|
@reconnect_count = @reconnect_count + 1
|
386
|
-
logger.info "
|
387
|
+
logger.info "Reconnect attempt #{@reconnect_count} of #{@reconnect_attempts}, sleeping for #{@reconnect_interval} seconds..."
|
387
388
|
sleep @reconnect_interval
|
388
389
|
retry if @reconnect_count < @reconnect_attempts
|
389
390
|
logger.info "Maximum number of failed reconnect attempts reached (#{@reconnect_attempts}). Exiting."
|
@@ -40,6 +40,18 @@ module HttpStreamingClient
|
|
40
40
|
"\033[0;37m[%s] \033[#{color}m%5s - %s\033[0m\n" % [time.to_s, severity, msg]
|
41
41
|
end
|
42
42
|
end
|
43
|
+
|
44
|
+
class BasicLogFormatter < Logger::Formatter
|
45
|
+
|
46
|
+
def call(severity, time, progname, msg)
|
47
|
+
"[%s] %s%s - %s\n" % [time.to_s, severity, @tag.nil? ? "" : "(#{@tag})", msg]
|
48
|
+
end
|
49
|
+
|
50
|
+
def tag=(tag)
|
51
|
+
@tag = tag
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
43
55
|
|
44
56
|
class CustomLoggerInternal
|
45
57
|
|
@@ -59,16 +71,22 @@ module HttpStreamingClient
|
|
59
71
|
def logfile=(enable)
|
60
72
|
return (@logfile = nil) if !enable
|
61
73
|
@logfile = Logger.new("test.log")
|
62
|
-
@logfile.formatter =
|
74
|
+
@logfile.formatter = BasicLogFormatter.new
|
63
75
|
@logfile.level = Logger::DEBUG
|
64
76
|
end
|
65
77
|
|
66
78
|
def console=(enable)
|
67
79
|
return (@console = nil) if !enable
|
68
80
|
@console = Logger.new(STDOUT)
|
69
|
-
@console.formatter =
|
81
|
+
@console.formatter = BasicLogFormatter.new
|
70
82
|
@console.level = Logger::INFO
|
71
83
|
end
|
84
|
+
|
85
|
+
def tag=(tag)
|
86
|
+
@console.formatter.tag = tag unless @console.nil?
|
87
|
+
@logfile.formatter.tag = tag unless @logfile.nil?
|
88
|
+
end
|
89
|
+
|
72
90
|
|
73
91
|
end
|
74
92
|
|
@@ -82,4 +100,5 @@ module HttpStreamingClient
|
|
82
100
|
def self.logger=(logger)
|
83
101
|
@custom_logger_internal = logger
|
84
102
|
end
|
103
|
+
|
85
104
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -20,6 +20,7 @@ RSpec.configure do |config|
|
|
20
20
|
HttpStreamingClient.logger.console = true
|
21
21
|
HttpStreamingClient.logger.level = Logger::DEBUG
|
22
22
|
HttpStreamingClient.logger.logfile = true
|
23
|
+
HttpStreamingClient.logger.tag = "rspec"
|
23
24
|
|
24
25
|
config.filter_run_excluding disabled: true
|
25
26
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http_streaming_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Tompkins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|