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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b62d37cbefddcdfb6b32bd89d683b1a34f9d710
4
- data.tar.gz: fea8030add8345a45e31c801def694b779c9ea84
3
+ metadata.gz: 9d60ec53bc8d52d27faaa4f781614dc5f054279d
4
+ data.tar.gz: 11cddfff56ead42495775d8049404a9e29e0e6ca
5
5
  SHA512:
6
- metadata.gz: f11a59dfd081b4c1da4132c13f8334be560cef1e80dfbc4997a9f6392ca76d56a36b1cea7bb8a7c29ccf19671d4ba392b434ab076fae1a4132c88239b17ef2d7
7
- data.tar.gz: 77f2680ae76b229c9c2d71518d6446bd45af0786ae8fc4a225509c2d1f2352dbb21cc33a6e003c27d2d4e9781ced01bbd5777e6d462f11a0b80eb1fb2be60917
6
+ metadata.gz: fc47d49144ea1c17f5fc531d2831bd9379a56c35c1cc8bbbbcf349f903e1d102c337a5ff6267c98aa96daf76b469fb09f5187ef1fd28e2f92783af693efe608d
7
+ data.tar.gz: 4c86071b9223e830bcf5f9b6981f4caa17733e3e31001f7f10818332b11c2c73ef088b1197779ad7dc17a95e45e4fc4db26c9fec4f3962e2c7635c1ea3cb0d2c
@@ -0,0 +1,12 @@
1
+ module Sapience
2
+ # rubocop:disable ClassVars
3
+ module Descendants
4
+ def descendants # :nodoc:
5
+ descendants = []
6
+ ObjectSpace.each_object(singleton_class) do |k|
7
+ descendants.unshift k unless k == self
8
+ end
9
+ descendants
10
+ end
11
+ end
12
+ end
@@ -4,13 +4,7 @@ require "sapience/extensions/grape/middleware/logging"
4
4
 
5
5
  module Grape
6
6
  class API
7
- def self.descendants # :nodoc:
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
 
@@ -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
@@ -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 } },
@@ -2,13 +2,7 @@ require "sapience"
2
2
 
3
3
  module Sneakers
4
4
  module Worker
5
- def self.descendants # :nodoc:
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
 
@@ -7,6 +7,8 @@ module Sapience
7
7
  attr_accessor :formatter
8
8
  attr_writer :application, :host
9
9
 
10
+ extend Sapience::Descendants
11
+
10
12
  # Returns the current log level if set, otherwise it logs everything it receives
11
13
  def level
12
14
  @level || :trace
@@ -1,3 +1,3 @@
1
1
  module Sapience
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
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.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.6.6
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.