logsly 1.3.2 → 1.3.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: 7468a6fbc210718d790d9fa8f534da73614b2374
4
- data.tar.gz: 2da77f41fce035a41d924f6cdfc5e18fc66b0287
3
+ metadata.gz: e161d2c0d18dc40b810f38f9591460cc8435ebb6
4
+ data.tar.gz: 5458e34127fb730f9739d44dc9e25aa93c6d30f4
5
5
  SHA512:
6
- metadata.gz: 20dae74d64ad543d4726d00199388ef1c1a851c34e7fe66f784763fe812f30a2749f1d784a00e4ff8058da4a9c17e2e55c3add892d9b2b54b78a6e6c2de29cb6
7
- data.tar.gz: 0335b12da4bf91cecdddef0b93907c6e5b592d0b0680fb88eb17e7ca3254143f84bfb02c5df4f95fcd4970c8a4d5739ae8058f5b9dfeb2388023f120926cdf72
6
+ metadata.gz: 05b04ce8e852655f3905046e167731298a56d0e97f09922c2d6b2dc426a97a1837c07ab1b80d4d0a9c9cf750b5ff18e499430e856cc331d53799df33d4f21a94
7
+ data.tar.gz: 16f8af3abc0d39c5dce1597999cd226e02326bb4aaf61d5948e04e86dd24639e78e4057d386223b1858cb9cdd556c1e5d43e9b2bbf7f1fbe3e80cb3a6a50fdf8
@@ -63,7 +63,7 @@ module Logsly
63
63
  output_data = output.data(self)
64
64
 
65
65
  # prefer output-specific level; fall back to general level
66
- logger.level = output_data ? output_data.level : @level
66
+ logger.level = output_data && output_data.level ? output_data.level : @level
67
67
  add_appender(logger, output.to_appender(output_data))
68
68
 
69
69
  hash[output_name] = logger
@@ -1,3 +1,3 @@
1
1
  module Logsly
2
- VERSION = "1.3.2"
2
+ VERSION = "1.3.3"
3
3
  end
@@ -107,8 +107,14 @@ module Logsly
107
107
  class LoggerTests < UnitTests
108
108
  desc "logger"
109
109
  setup do
110
+ # this populates the `Logsly::Logging182::LEVELS` constant
111
+ Logsly::Logging182.init
112
+
110
113
  @logger = TestLogger.new(:testy_log_logger)
111
114
  end
115
+ teardown do
116
+ Logsly.reset
117
+ end
112
118
  subject{ @logger }
113
119
 
114
120
  should have_readers :log_type, :level, :outputs, :output_loggers
@@ -134,11 +140,14 @@ module Logsly
134
140
  assert_equal [:stdout], log.outputs
135
141
  end
136
142
 
137
- should "create a Logsly::Logging182::Logger for each output" do
143
+ should "not have any output loggers by default" do
138
144
  assert_empty subject.output_loggers
145
+ end
139
146
 
147
+ should "create a Logsly::Logging182::Logger for each output" do
140
148
  outputs = Factory.integer(3).times.map{ Factory.string }
141
149
  log = TestLogger.new(:testy_log_logger, :outputs => outputs)
150
+ assert_equal outputs.size, log.output_loggers.size
142
151
  outputs.each do |output|
143
152
  logger = log.output_loggers[output]
144
153
  assert_kind_of Logsly::Logging182::Logger, logger
@@ -152,6 +161,45 @@ module Logsly
152
161
  end
153
162
  end
154
163
 
164
+ should "default a configured outputs level when creating loggers" do
165
+ output_name = Factory.string
166
+ Logsly.stdout(output_name){ } # don't set a `level`
167
+
168
+ log = TestLogger.new(:testy_log_logger, :outputs => [output_name])
169
+ logger = log.output_loggers[output_name]
170
+ assert_kind_of Logsly::Logging182::Logger, logger
171
+ assert_equal Logsly::Logging182::LEVELS[DEFAULT_LEVEL], logger.level
172
+ end
173
+
174
+ should "use the configured outputs level when creating loggers" do
175
+ output_name = Factory.string
176
+ custom_log_level = Logsly::Logging182::LEVELS.keys.choice
177
+ Logsly.stdout(output_name){ level(custom_log_level) }
178
+
179
+ passed_log_level = (Logsly::Logging182::LEVELS.keys - [custom_log_level]).choice
180
+ log = TestLogger.new(:testy_log_logger, {
181
+ :level => passed_log_level,
182
+ :outputs => [output_name]
183
+ })
184
+ logger = log.output_loggers[output_name]
185
+ assert_kind_of Logsly::Logging182::Logger, logger
186
+ assert_equal Logsly::Logging182::LEVELS[custom_log_level], logger.level
187
+ end
188
+
189
+ should "use a passed output level when creating loggers" do
190
+ output_name = Factory.string
191
+ Logsly.stdout(output_name){ } # don't set a `level`
192
+
193
+ passed_log_level = Logsly::Logging182::LEVELS.keys.choice
194
+ log = TestLogger.new(:testy_log_logger, {
195
+ :level => passed_log_level,
196
+ :outputs => [output_name]
197
+ })
198
+ logger = log.output_loggers[output_name]
199
+ assert_kind_of Logsly::Logging182::Logger, logger
200
+ assert_equal Logsly::Logging182::LEVELS[passed_log_level], logger.level
201
+ end
202
+
155
203
  should "set mdc key/value pairs" do
156
204
  key = Factory.string
157
205
  assert_nil Logsly::Logging182.mdc[key]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logsly
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Redding
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2016-07-09 00:00:00 Z
13
+ date: 2016-11-08 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: assert
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  requirements: []
132
132
 
133
133
  rubyforge_project:
134
- rubygems_version: 2.6.4
134
+ rubygems_version: 2.6.7
135
135
  signing_key:
136
136
  specification_version: 4
137
137
  summary: Create custom loggers.