sapience 0.1.5 → 0.1.6

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: 78c16638deb885ad6b022355c8122c6d2b04abf1
4
- data.tar.gz: ac30e445702caf63218ee9cbe8231ae4d3136959
3
+ metadata.gz: b620c9f4e3bab1dc13730e041f5fb7392b3905c7
4
+ data.tar.gz: 5b7ea012ee80f8a267e3c57791624afe3ba1f4f1
5
5
  SHA512:
6
- metadata.gz: fa40581925e5d0f63b433f3cf845e68fc8ca36c699640cdaa64f65797dbfc3c8959d8720e0941a5754680c171692322af6a2c6bfc843ac549795709ea4277784
7
- data.tar.gz: f14ffb78c47bd8fe3d68bd90292d4b0d04f3ff6404bc6930e86d9fe7cf876753820f7ee105671fed1a4c1a55190d762ba7c9ccae0e8b77fdd263d332717ccca9
6
+ metadata.gz: 7a5ffe52b3de2eef007e81aeac35efaea59e48fe93ad79b6eefc2d7e973bdbcc29683a69440965668493a8451a4495a0dcfd30eea205a048d96a9246db9c29c4
7
+ data.tar.gz: 3e75783787e99e1c70d5c4540190a4e91fdf8ac907360d8a197a6f64382951ac3f309c4585dadf57157f4d81b936c8a260cab5ddba75b08dd6a71773ffc891d0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.1.6
2
+
3
+ - Prevent configuring twice (adds double appenders)
4
+
1
5
  ## v0.1.5
2
6
 
3
7
  - Add missing `#time` method for datadog
data/config/default.yml CHANGED
@@ -26,4 +26,3 @@ production:
26
26
  - file:
27
27
  file_name: log/production.log
28
28
  formatter: json
29
-
@@ -18,10 +18,7 @@ require "socket"
18
18
 
19
19
  # rubocop:disable ClassVars
20
20
  module Sapience
21
- # 1. Have a default configuration
22
- # 2. Configure Sapience (Sapience.configure { |c| c.configuration = {} })
23
- # 3. Use configuration for rails
24
- # 4. Use configuration for grape
21
+ @@configured = nil
25
22
 
26
23
  # Logging levels in order of most detailed to most severe
27
24
  LEVELS = [:trace, :debug, :info, :warn, :error, :fatal]
@@ -38,10 +35,15 @@ module Sapience
38
35
  end
39
36
  end
40
37
 
38
+ def self.configured?
39
+ @@configured
40
+ end
41
+
41
42
  def self.reset!
42
43
  @@config = nil
43
44
  @@logger = nil
44
45
  @@metrix = nil
46
+ @@configured = nil
45
47
  reset_appenders!
46
48
  end
47
49
 
@@ -57,14 +59,11 @@ module Sapience
57
59
  end
58
60
  end
59
61
 
60
- def self.configure
62
+ def self.configure(force: false)
61
63
  yield config if block_given?
62
-
63
- config.appenders.each do |appender|
64
- appender.each do |name, options|
65
- add_appender(name, options)
66
- end
67
- end
64
+ return config if configured? && force == false
65
+ add_appenders(*config.appenders)
66
+ @@configured = true
68
67
 
69
68
  config
70
69
  end
@@ -166,6 +165,18 @@ module Sapience
166
165
  appender
167
166
  end
168
167
 
168
+ # Examples:
169
+ # Sapience.add_appenders(
170
+ # { file: { io: STDOUT } },
171
+ # { sentry: { dsn: "https://app.getsentry.com/" } },
172
+ # )
173
+ def self.add_appenders(*appenders)
174
+ appenders.flatten.compact.each do |appender|
175
+ appender.each do |name, options|
176
+ add_appender(name, options)
177
+ end
178
+ end
179
+ end
169
180
 
170
181
  # Remove an existing appender
171
182
  # Currently only supports appender instances
@@ -1,3 +1,3 @@
1
1
  module Sapience
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
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.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson