right_support 2.9.4 → 2.9.5

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: f8cb5d377a3622ac5ba6240f5fb6e3554596f664
4
- data.tar.gz: 4c77349b228d4a892a956d5afcd4284ff4865bd9
3
+ metadata.gz: 4ac847f015800780b7756c78dc5fdd714758aa83
4
+ data.tar.gz: 3bdeecf991d8e3284406b0e921d1d0a78fabaccc
5
5
  SHA512:
6
- metadata.gz: d32d8853b71c7579647a687237187925fe12e3e0942d51e827751b8adb24500e53107aa0ec5f7fc2fb28fbec6b2a91591ac0bacf5cd48d555edd179d3ddbf1d5
7
- data.tar.gz: 917e614a451fa81bea1ae1203168650be8bd392cfe44082d28580bce1ed3eab6cdeeb4498bc9767b75466fda4413255766d385300941960260418b8127944b2b
6
+ metadata.gz: 88e1bcf8bddd85d7142e621a50db1cc4c1721cd67788ab156561ab1d85436287a832d578378d9fe7a82b4c2f1e4b9b49cdde786cad501eebb2c61ea9270749ae
7
+ data.tar.gz: e23752f713f25827b49b51a9981e79d5c1adb1cff40e441d86cde7b9177075960209bafbfcffed2472dfc9872dbd9a08db8d72708ef1a108008c06d3c7238c5d
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.9.4
1
+ 2.9.5
@@ -93,6 +93,7 @@ module RightSupport::Log::Syslog
93
93
  attempts = 0
94
94
  begin
95
95
  @socket = opener.call
96
+ @socket.sync = true
96
97
  rescue => e
97
98
  # do not repeat backoff/retry when already in error mode.
98
99
  raise if @error_mode
@@ -151,57 +152,69 @@ module RightSupport::Log::Syslog
151
152
  end
152
153
 
153
154
  def log(facility, severity, message)
155
+ # Normally, use a mutex to ensure threadsafe logging
156
+ @mutex.synchronize do
157
+ log_without_thread_safety(facility, severity, message)
158
+ end
159
+ true
160
+ rescue ThreadError => e
161
+ # Sometimes the mutex can't be acquired (e.g. when servicing a trap);
162
+ #
163
+ log_without_thread_safety(facility, severity, message)
164
+ true
165
+ end
166
+
167
+ private
168
+
169
+ def log_without_thread_safety(facility, severity, message)
170
+ last_error = nil
171
+
154
172
  protocol_message = "<#{(facility & 0xf8) | (severity & 0x07)}> "\
155
173
  "#{::Time.now.strftime('%b %d %H:%M:%S')} " \
156
174
  "#{@hostname} " \
157
175
  "#{@identity}" \
158
176
  ": " \
159
177
  "#{message.gsub("\n", '#012')}\n"
160
- @mutex.synchronize do
161
- last_error = nil
162
- begin
163
- @socket.write(protocol_message)
164
- rescue => e
165
- if reconnect
166
- begin
167
- @socket.write(protocol_message)
168
- rescue => e
169
- last_error = e
170
- end
171
- else
178
+
179
+ begin
180
+ @socket.write(protocol_message)
181
+ rescue => e
182
+ if reconnect
183
+ begin
184
+ @socket.write(protocol_message)
185
+ rescue => e
172
186
  last_error = e
173
187
  end
188
+ else
189
+ last_error = e
174
190
  end
175
- if last_error
176
- # we are only here if reconnection attempts have timed out at least
177
- # once. the timeout is skipped when we are already in error mode.
178
- if @error_mode
179
- # no need to repeat the warning or invoke callback for each
180
- # failure to write.
181
- ::STDERR.puts(protocol_message)
182
- else
183
- @error_mode = true
184
- msg = <<EOF
191
+ end
192
+ if last_error
193
+ # we are only here if reconnection attempts have timed out at least
194
+ # once. the timeout is skipped when we are already in error mode.
195
+ if @error_mode
196
+ # no need to repeat the warning or invoke callback for each
197
+ # failure to write.
198
+ ::STDERR.puts(protocol_message)
199
+ else
200
+ @error_mode = true
201
+ msg = <<EOF
185
202
  WARNING: Failed writing to syslog: #{last_error.message}
186
- Dumping raw messages to stderr until rsyslog connection is restored.
203
+ Dumping raw messages to stderr until syslog connection is restored.
187
204
  EOF
188
- ::STDERR.puts(msg)
189
- ::STDERR.puts(protocol_message)
205
+ ::STDERR.puts(msg)
206
+ ::STDERR.puts(protocol_message)
190
207
 
191
- # the caller may want to gracefully shutdown, etc. graceful shutdown
192
- # will trigger alerts whereas silently ignoring failure to write to
193
- # syslog can lead to other problems.
194
- @error_handler.call(last_error) if @error_handler
195
- end
196
- else
197
- @error_mode = false
208
+ # the caller may want to gracefully shutdown, etc. graceful shutdown
209
+ # will trigger alerts whereas silently ignoring failure to write to
210
+ # syslog can lead to other problems.
211
+ @error_handler.call(last_error) if @error_handler
198
212
  end
213
+ else
214
+ @error_mode = false
199
215
  end
200
- true
201
216
  end
202
217
 
203
- private
204
-
205
218
  def reconnect
206
219
  connect
207
220
  true
@@ -2,19 +2,20 @@
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.4 ruby lib
5
+ # stub: right_support 2.9.5 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "right_support"
9
- s.version = "2.9.4"
9
+ s.version = "2.9.5"
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 = "2016-03-16"
14
+ s.date = "2016-03-21"
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 = [
18
+ "CHANGELOG.rdoc",
18
19
  "LICENSE",
19
20
  "README.md"
20
21
  ]
@@ -149,7 +150,7 @@ Gem::Specification.new do |s|
149
150
  ]
150
151
  s.homepage = "https://github.com/rightscale/right_support"
151
152
  s.licenses = ["MIT"]
152
- s.rubygems_version = "2.5.1"
153
+ s.rubygems_version = "2.4.5"
153
154
  s.summary = "Reusable foundation code."
154
155
 
155
156
  if s.respond_to? :specification_version then
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.4
4
+ version: 2.9.5
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: 2016-03-16 00:00:00.000000000 Z
16
+ date: 2016-03-21 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rake
@@ -90,6 +90,7 @@ email: support@rightscale.com
90
90
  executables: []
91
91
  extensions: []
92
92
  extra_rdoc_files:
93
+ - CHANGELOG.rdoc
93
94
  - LICENSE
94
95
  - README.md
95
96
  files:
@@ -240,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
241
  version: '0'
241
242
  requirements: []
242
243
  rubyforge_project:
243
- rubygems_version: 2.5.1
244
+ rubygems_version: 2.4.5
244
245
  signing_key:
245
246
  specification_version: 4
246
247
  summary: Reusable foundation code.