sapience 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sapience/descendants.rb +12 -0
- data/lib/sapience/grape.rb +1 -7
- data/lib/sapience/logger.rb +1 -1
- data/lib/sapience/sapience.rb +14 -0
- data/lib/sapience/sneakers.rb +1 -7
- data/lib/sapience/subscriber.rb +2 -0
- data/lib/sapience/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d60ec53bc8d52d27faaa4f781614dc5f054279d
|
4
|
+
data.tar.gz: 11cddfff56ead42495775d8049404a9e29e0e6ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc47d49144ea1c17f5fc531d2831bd9379a56c35c1cc8bbbbcf349f903e1d102c337a5ff6267c98aa96daf76b469fb09f5187ef1fd28e2f92783af693efe608d
|
7
|
+
data.tar.gz: 4c86071b9223e830bcf5f9b6981f4caa17733e3e31001f7f10818332b11c2c73ef088b1197779ad7dc17a95e45e4fc4db26c9fec4f3962e2c7635c1ea3cb0d2c
|
data/lib/sapience/grape.rb
CHANGED
@@ -4,13 +4,7 @@ require "sapience/extensions/grape/middleware/logging"
|
|
4
4
|
|
5
5
|
module Grape
|
6
6
|
class API
|
7
|
-
|
8
|
-
descendants = []
|
9
|
-
ObjectSpace.each_object(singleton_class) do |k|
|
10
|
-
descendants.unshift k unless k == self
|
11
|
-
end
|
12
|
-
descendants
|
13
|
-
end
|
7
|
+
extend Sapience::Descendants
|
14
8
|
end
|
15
9
|
end
|
16
10
|
|
data/lib/sapience/logger.rb
CHANGED
@@ -39,7 +39,7 @@ module Sapience
|
|
39
39
|
appender_thread << lambda do
|
40
40
|
Sapience.appenders.each do |appender|
|
41
41
|
begin
|
42
|
-
logger.trace "Appender thread: Flushing appender: #{appender.name}"
|
42
|
+
logger.trace "Appender thread: Flushing appender: #{appender.class.name}"
|
43
43
|
appender.flush
|
44
44
|
rescue StandardError => exc
|
45
45
|
logger.error "Appender thread: Failed to flush appender: #{appender.inspect}", exc
|
data/lib/sapience/sapience.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "concurrent"
|
2
2
|
require "socket"
|
3
|
+
require "sapience/descendants"
|
3
4
|
|
4
5
|
# Example:
|
5
6
|
#
|
@@ -163,6 +164,8 @@ module Sapience
|
|
163
164
|
fail ArgumentError, "options should be a hash" unless options.is_a?(Hash)
|
164
165
|
options.deep_symbolize_keys!
|
165
166
|
appender_class = constantize_symbol(appender)
|
167
|
+
validate_appender!(appender_class)
|
168
|
+
|
166
169
|
appender = appender_class.new(options)
|
167
170
|
@@appenders << appender
|
168
171
|
|
@@ -173,6 +176,17 @@ module Sapience
|
|
173
176
|
appender
|
174
177
|
end
|
175
178
|
|
179
|
+
def self.validate_appender!(appender)
|
180
|
+
return if known_appenders.include?(appender)
|
181
|
+
|
182
|
+
fail NotImplementedError,
|
183
|
+
"Unknown appender '#{appender}'. Supported appenders are (#{known_appenders.join(", ")})"
|
184
|
+
end
|
185
|
+
|
186
|
+
def self.known_appenders
|
187
|
+
@_known_appenders ||= Sapience::Subscriber.descendants
|
188
|
+
end
|
189
|
+
|
176
190
|
# Examples:
|
177
191
|
# Sapience.add_appenders(
|
178
192
|
# { file: { io: STDOUT } },
|
data/lib/sapience/sneakers.rb
CHANGED
@@ -2,13 +2,7 @@ require "sapience"
|
|
2
2
|
|
3
3
|
module Sneakers
|
4
4
|
module Worker
|
5
|
-
|
6
|
-
descendants = []
|
7
|
-
ObjectSpace.each_object(singleton_class) do |k|
|
8
|
-
descendants.unshift k unless k == self
|
9
|
-
end
|
10
|
-
descendants
|
11
|
-
end
|
5
|
+
extend Sapience::Descendants
|
12
6
|
end
|
13
7
|
end
|
14
8
|
|
data/lib/sapience/subscriber.rb
CHANGED
data/lib/sapience/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sapience
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikael Henriksson
|
@@ -219,6 +219,7 @@ files:
|
|
219
219
|
- lib/sapience/configuration/grape.rb
|
220
220
|
- lib/sapience/core_ext/hash.rb
|
221
221
|
- lib/sapience/core_ext/thread.rb
|
222
|
+
- lib/sapience/descendants.rb
|
222
223
|
- lib/sapience/extensions/action_cable/tagged_logger_proxy.rb
|
223
224
|
- lib/sapience/extensions/action_controller/live.rb
|
224
225
|
- lib/sapience/extensions/action_controller/log_subscriber.rb
|
@@ -358,7 +359,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
358
359
|
version: '0'
|
359
360
|
requirements: []
|
360
361
|
rubyforge_project:
|
361
|
-
rubygems_version: 2.
|
362
|
+
rubygems_version: 2.5.1
|
362
363
|
signing_key:
|
363
364
|
specification_version: 4
|
364
365
|
summary: Hasslefree autoconfiguration for logging, metrics and exception collection.
|