right_support 2.9.6 → 2.10.1
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/.travis.yml +0 -4
- data/Gemfile.lock +2 -2
- data/VERSION +1 -1
- data/lib/right_support/log.rb +1 -0
- data/lib/right_support/log/filter_logger.rb +9 -2
- data/lib/right_support/log/step_level_logger.rb +58 -0
- data/right_support.gemspec +4 -5
- data/spec/log/step_level_logger_spec.rb +49 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45713709a34db9049a788ea3bd6e371bc9cdcb2c
|
4
|
+
data.tar.gz: 9ae79e61f4b120b3bdc15c03da6df873d8bed016
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4eef7bc6bc87bcd4c275935533be46b4f222291fce03e48a995595c952d0d8116cba0ce6fe1769ec660b3ec92536a112aa3008a40a4283c4f9a4ea4d9c2017a
|
7
|
+
data.tar.gz: 5074d0f87841daa8df2a59dfcf4f9ca0e724ee0c9cdc1748ebe07719b1fa7e513722e8bb24b92eb4aee3047c44d5fe45cf553bd5d3c24411ecd89ceb200ec84c
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.10.1
|
data/lib/right_support/log.rb
CHANGED
@@ -67,6 +67,7 @@ module RightSupport::Log
|
|
67
67
|
# See #info for more information.
|
68
68
|
def debug(message = nil, &block)
|
69
69
|
severity, message = filter(DEBUG, message_to_string(message))
|
70
|
+
return true if severity.nil?
|
70
71
|
meth = SEVERITY_TO_METHOD[severity]
|
71
72
|
raise ArgumentError, "Filter emitted unknown severity #{severity.inspect}" unless meth
|
72
73
|
@actual_logger.__send__(meth, message, &block)
|
@@ -78,6 +79,7 @@ module RightSupport::Log
|
|
78
79
|
# See #info for more information.
|
79
80
|
def info(message = nil, &block)
|
80
81
|
severity, message = filter(INFO, message_to_string(message))
|
82
|
+
return true if severity.nil?
|
81
83
|
meth = SEVERITY_TO_METHOD[severity]
|
82
84
|
raise ArgumentError, "Filter emitted unknown severity #{severity.inspect}" unless meth
|
83
85
|
@actual_logger.__send__(meth, message, &block)
|
@@ -89,6 +91,7 @@ module RightSupport::Log
|
|
89
91
|
# See #info for more information.
|
90
92
|
def warn(message = nil, &block)
|
91
93
|
severity, message = filter(WARN, message_to_string(message))
|
94
|
+
return true if severity.nil?
|
92
95
|
meth = SEVERITY_TO_METHOD[severity]
|
93
96
|
raise ArgumentError, "Filter emitted unknown severity #{severity.inspect}" unless meth
|
94
97
|
@actual_logger.__send__(meth, message, &block)
|
@@ -100,6 +103,7 @@ module RightSupport::Log
|
|
100
103
|
# See #info for more information.
|
101
104
|
def error(message = nil, &block)
|
102
105
|
severity, message = filter(ERROR, message_to_string(message))
|
106
|
+
return if severity.nil?
|
103
107
|
meth = SEVERITY_TO_METHOD[severity]
|
104
108
|
raise ArgumentError, "Filter emitted unknown severity #{severity.inspect}" unless meth
|
105
109
|
@actual_logger.__send__(meth, message, &block)
|
@@ -111,6 +115,7 @@ module RightSupport::Log
|
|
111
115
|
# See #info for more information.
|
112
116
|
def fatal(message = nil, &block)
|
113
117
|
severity, message = filter(FATAL, message_to_string(message))
|
118
|
+
return true if severity.nil?
|
114
119
|
meth = SEVERITY_TO_METHOD[severity]
|
115
120
|
raise ArgumentError, "Filter emitted unknown severity #{severity.inspect}" unless meth
|
116
121
|
@actual_logger.__send__(meth, message, &block)
|
@@ -144,6 +149,7 @@ module RightSupport::Log
|
|
144
149
|
end
|
145
150
|
|
146
151
|
severity, message = filter(severity, message_to_string(message))
|
152
|
+
return true if severity.nil?
|
147
153
|
return @actual_logger.add(severity, message) if message
|
148
154
|
end
|
149
155
|
|
@@ -185,14 +191,15 @@ module RightSupport::Log
|
|
185
191
|
protected
|
186
192
|
|
187
193
|
# Filter a log line, transforming its severity and/or message before it is
|
188
|
-
# passed to the underlying logger.
|
194
|
+
# passed to the underlying logger. Overridable.
|
189
195
|
#
|
190
196
|
# === Parameters
|
191
197
|
# severity(Integer):: one of the severity constants defined by Logger
|
192
198
|
# message(String):: the log message
|
193
199
|
#
|
194
200
|
# === Return
|
195
|
-
# Returns a pair consisting of the filtered [severity, message]
|
201
|
+
# Returns a pair consisting of the filtered [severity, message] or nil to
|
202
|
+
# indicate that the message has been filtered out
|
196
203
|
def filter(severity, message)
|
197
204
|
return [severity, message]
|
198
205
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2016 RightScale Inc
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
module RightSupport::Log
|
24
|
+
# a decorator that provides a step-level filter such that it can decorate a
|
25
|
+
# logger of more detailed level while allowing only messages of a less
|
26
|
+
# detailed level. for example, a logger can be associated with a database and
|
27
|
+
# omit debug-level messages from the db driver while allowing any errors,
|
28
|
+
# warnings, etc. to pass through to the web application logger. this allows
|
29
|
+
# for a unified log with specific level filtering for specific use cases.
|
30
|
+
#
|
31
|
+
# setting log level on this kind of logger does not set the level of the
|
32
|
+
# underlying logger (hence the name step-level).
|
33
|
+
class StepLevelLogger < FilterLogger
|
34
|
+
# declare accessor to prevent setting decorated logger level
|
35
|
+
attr_accessor :level
|
36
|
+
|
37
|
+
def initialize(*args)
|
38
|
+
super
|
39
|
+
@level = ::Logger::DEBUG
|
40
|
+
end
|
41
|
+
|
42
|
+
protected
|
43
|
+
|
44
|
+
# Uses step-level to filter messages before invoking decorated logger.
|
45
|
+
#
|
46
|
+
# === Parameters
|
47
|
+
# severity(Integer):: one of the severity constants defined by Logger
|
48
|
+
# message(String):: the log message
|
49
|
+
#
|
50
|
+
# === Return
|
51
|
+
# Returns a pair consisting of the filtered [severity, message] or nil to
|
52
|
+
# indicate that the message has been filtered out
|
53
|
+
def filter(severity, message)
|
54
|
+
return nil if severity < level
|
55
|
+
super
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/right_support.gemspec
CHANGED
@@ -2,20 +2,19 @@
|
|
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.
|
5
|
+
# stub: right_support 2.10.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "right_support"
|
9
|
-
s.version = "2.
|
9
|
+
s.version = "2.10.1"
|
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-
|
14
|
+
s.date = "2016-06-01"
|
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",
|
19
18
|
"LICENSE",
|
20
19
|
"README.md"
|
21
20
|
]
|
@@ -150,7 +149,7 @@ Gem::Specification.new do |s|
|
|
150
149
|
]
|
151
150
|
s.homepage = "https://github.com/rightscale/right_support"
|
152
151
|
s.licenses = ["MIT"]
|
153
|
-
s.rubygems_version = "2.
|
152
|
+
s.rubygems_version = "2.2.5"
|
154
153
|
s.summary = "Reusable foundation code."
|
155
154
|
|
156
155
|
if s.respond_to? :specification_version then
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require ::File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
describe RightSupport::Log::StepLevelLogger do
|
5
|
+
context 'with a decorated logger' do
|
6
|
+
let(:buffer) { ::StringIO.new }
|
7
|
+
|
8
|
+
let(:decorated_logger) { ::Logger.new(buffer) }
|
9
|
+
|
10
|
+
def try_all_levels(l)
|
11
|
+
l.debug('debug')
|
12
|
+
l.info('info')
|
13
|
+
l.warn('warn')
|
14
|
+
l.error('error')
|
15
|
+
l.fatal('fatal')
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with default level' do
|
19
|
+
subject { described_class.new(decorated_logger) }
|
20
|
+
|
21
|
+
it 'passes all messages' do
|
22
|
+
try_all_levels(subject)
|
23
|
+
buffer.string.should =~ /debug.+info.+warn.+error.+fatal/m
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'with error level' do
|
28
|
+
subject do
|
29
|
+
s = described_class.new(decorated_logger)
|
30
|
+
s.level = ::Logger::ERROR
|
31
|
+
s
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'passes error and fatal messages' do
|
35
|
+
try_all_levels(subject)
|
36
|
+
buffer.string.should_not =~ /debug/
|
37
|
+
buffer.string.should_not =~ /info/
|
38
|
+
buffer.string.should_not =~ /warn/
|
39
|
+
buffer.string.should =~ /error.+fatal/m
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'does not change level of decorated logger' do
|
43
|
+
try_all_levels(decorated_logger)
|
44
|
+
buffer.string.should =~ /debug.+info.+warn.+error.+fatal/m
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
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.
|
4
|
+
version: 2.10.1
|
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-
|
16
|
+
date: 2016-06-01 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: rake
|
@@ -90,7 +90,6 @@ email: support@rightscale.com
|
|
90
90
|
executables: []
|
91
91
|
extensions: []
|
92
92
|
extra_rdoc_files:
|
93
|
-
- CHANGELOG.rdoc
|
94
93
|
- LICENSE
|
95
94
|
- README.md
|
96
95
|
files:
|
@@ -145,6 +144,7 @@ files:
|
|
145
144
|
- lib/right_support/log/mixin.rb
|
146
145
|
- lib/right_support/log/multiplexer.rb
|
147
146
|
- lib/right_support/log/null_logger.rb
|
147
|
+
- lib/right_support/log/step_level_logger.rb
|
148
148
|
- lib/right_support/log/syslog/remote.rb
|
149
149
|
- lib/right_support/log/system_logger.rb
|
150
150
|
- lib/right_support/net.rb
|
@@ -197,6 +197,7 @@ files:
|
|
197
197
|
- spec/log/mixin_spec.rb
|
198
198
|
- spec/log/multiplexer_spec.rb
|
199
199
|
- spec/log/null_logger_spec.rb
|
200
|
+
- spec/log/step_level_logger_spec.rb
|
200
201
|
- spec/log/system_logger_spec.rb
|
201
202
|
- spec/net/address_helper_spec.rb
|
202
203
|
- spec/net/balancing/health_check_spec.rb
|
@@ -241,9 +242,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
241
242
|
version: '0'
|
242
243
|
requirements: []
|
243
244
|
rubyforge_project:
|
244
|
-
rubygems_version: 2.2.
|
245
|
+
rubygems_version: 2.2.5
|
245
246
|
signing_key:
|
246
247
|
specification_version: 4
|
247
248
|
summary: Reusable foundation code.
|
248
249
|
test_files: []
|
249
|
-
has_rdoc:
|