right_support 2.9.1 → 2.9.2

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: c00cbfd4e07ebbe5552f5ad98a567c61b66cc3f8
4
- data.tar.gz: 10a8a64f785328beee4becbc12a9ccce43c42807
3
+ metadata.gz: e2215ed9e7706511edfcd6ea56abf45486749d9d
4
+ data.tar.gz: 15fac74e4fcb14b20b32f4de9a6087388bf3310b
5
5
  SHA512:
6
- metadata.gz: fbf3db59b98e9b18274aceec2790a9513953e25128f33b264b7ab95966a16772d6529291913dbeeeb2a79964246b7e665fecc8702186531cf8b1ed787b5ce063
7
- data.tar.gz: 3c56b3ffcba5b0425be7772a15c2680f2918d2a102dfd99b1d3259c5d4fe53ad847648eb2a7aaae245e5f6c741e6cd03b17b3c7ca38f38c556e9899f92ac4aef
6
+ metadata.gz: 0bae6ef9d208192d1a73104c5f1178895ea3b27b09cbc09f84f017d2849c0f66a8b2c81959c52a3d7f0988575b77be9cd2065b2a3ab4d770852da45c9229de29
7
+ data.tar.gz: 4de8efb3cfd6d0c76c16875749fb681a3909c6ee6f6bf5fb1d3f7399c02039bdccfa547ea2460cbf824bc26ba6a99be51288ac609c7e2177e5ffa37590a70eea
data/Gemfile.lock CHANGED
@@ -93,7 +93,7 @@ GEM
93
93
  right_git (1.0.1)
94
94
  right_support (>= 2.8.10)
95
95
  right_http_connection (1.5.0)
96
- right_support (2.8.32)
96
+ right_support (2.9.1)
97
97
  rspec (2.13.0)
98
98
  rspec-core (~> 2.13.0)
99
99
  rspec-expectations (~> 2.13.0)
@@ -148,3 +148,6 @@ DEPENDENCIES
148
148
  simple_uuid (~> 0.2)
149
149
  uuid (~> 2.3)
150
150
  uuidtools (~> 2.0)
151
+
152
+ BUNDLED WITH
153
+ 1.10.6
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.9.1
1
+ 2.9.2
@@ -137,25 +137,26 @@ module RightSupport::Log
137
137
  end
138
138
  end
139
139
 
140
- case @options[:connection]
141
- when :local
142
- @@syslog = ::Syslog.open(program_name, nil, facility)
143
- else
144
- require ::File.expand_path('../syslog/remote', __FILE__)
145
- syslogger = ::RightSupport::Log::Syslog::Remote.new(
146
- @options[:connection],
147
- program_name,
148
- facility,
149
- :error_handler => @options[:error_handler])
150
- syslogger.connect
151
- @@syslog = syslogger
152
- end
140
+ # connect
141
+ @@program_name = program_name
142
+ @@facility = facility
143
+ establish_connection
153
144
  end
154
- @@program_name = program_name
155
145
  end
156
146
  @@syslog.info("Connected to syslog: #{@options[:connection].inspect}")
157
147
  end
158
148
 
149
+ # Reconnects using the established connection details. This is useful to
150
+ # ensure the rainbows child processes show their own PID, etc.
151
+ #
152
+ # @return [TrueClass] always true
153
+ def reconnect
154
+ @@mutex.synchronize do
155
+ establish_connection
156
+ end
157
+ true
158
+ end
159
+
159
160
  # Log a message if the given severity is high enough. This is the generic
160
161
  # logging method. Users will be more inclined to use #debug, #info, #warn,
161
162
  # #error, and #fatal.
@@ -217,6 +218,29 @@ module RightSupport::Log
217
218
 
218
219
  private
219
220
 
221
+ # (re)establishes connection and sets the class constant for logger.
222
+ def establish_connection
223
+ case @options[:connection]
224
+ when :local
225
+ if @@syslog
226
+ @@syslog.reopen(@@program_name, nil, @@facility)
227
+ else
228
+ @@syslog = ::Syslog.open(@@program_name, nil, @@facility)
229
+ end
230
+ else
231
+ require ::File.expand_path('../syslog/remote', __FILE__)
232
+ syslogger = ::RightSupport::Log::Syslog::Remote.new(
233
+ @options[:connection],
234
+ @@program_name,
235
+ @@facility,
236
+ :error_handler => @options[:error_handler])
237
+ syslogger.connect
238
+ @@syslog.close if @@syslog
239
+ @@syslog = syslogger
240
+ end
241
+ true
242
+ end
243
+
220
244
  # Call the syslog function to emit a syslog entry.
221
245
  #
222
246
  # === Parameters
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: right_support 2.9.1 ruby lib
5
+ # stub: right_support 2.9.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "right_support"
9
- s.version = "2.9.1"
9
+ s.version = "2.9.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Tony Spataro", "Sergey Sergyenko", "Ryan Williamson", "Lee Kirchhoff", "Alexey Karpik", "Scott Messier"]
14
- s.date = "2015-09-23"
14
+ s.date = "2015-10-09"
15
15
  s.description = "A toolkit of useful, reusable foundation code created by RightScale."
16
16
  s.email = "support@rightscale.com"
17
17
  s.extra_rdoc_files = [
@@ -139,6 +139,33 @@ describe 'RightSupport::Log::SystemLogger' do
139
139
  # example: "<134> Sep 23 13:45:42 ubuntu spec[3891]: Connected to syslog: \"tcp://localhost:2345\"\n"
140
140
  regex = /^<134> \w+ \d+ \d+:\d+:\d+ .+ spec\[\d+\]: Connected to syslog: \"tcp:\/\/localhost:2345\"$/
141
141
  data.chomp.should match(regex)
142
+
143
+ # attempt to reconnect to closed server.
144
+ server.close
145
+ server = nil
146
+ data = nil
147
+ ::Thread.start do
148
+ sleep 1 # should cause 1-2 reconnect error(s) to appear in STDERR
149
+ server = ::TCPServer.new(2345)
150
+ client = server.accept
151
+ data = client.readline
152
+ client.close
153
+ server.close
154
+ server = nil
155
+ end
156
+
157
+ # explicitly reconnect and send with delayed server restart. reconnection
158
+ # happens automagically (only for remote) but explicit reconnection will
159
+ # reestablish the PID, etc., which is useful for forking.
160
+ logger.reconnect
161
+ logger.debug("Hello syslog")
162
+ stop_time = ::Time.now + 3
163
+ while data.nil?
164
+ sleep(0.1)
165
+ fail 'Did not receive expected data' if ::Time.now >= stop_time
166
+ end
167
+ regex = /^<135> \w+ \d+ \d+:\d+:\d+ .+ spec\[\d+\]: Hello syslog$/
168
+ data.chomp.should match(regex)
142
169
  end
143
170
  end
144
171
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.1
4
+ version: 2.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Spataro
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2015-09-23 00:00:00.000000000 Z
16
+ date: 2015-10-09 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rake