semantic_logger 4.3.0 → 4.3.1
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 285869f2b402ea378eab2606d3d72f7b7be3db56102bea2c530a98411a077d6c
|
4
|
+
data.tar.gz: cab30b7d7bcfda6083716a530aeedf20192b1fa1c3a83c7cb237d475516d0ca7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e67d39bfbedb72f64b191f75d5786f521d311d78fb243bb97cbfa948333fcfa21f89ebcfa6a9ac34696a24c359bd8b67a9617228a25a1958bbf3092ed6324472
|
7
|
+
data.tar.gz: c446a8410247e2b8393f401182f0bc1a266d329ce1190328a3f7253bf5b64273c87c5db05a4bb4f808caf9435b0e8a8d2a37a69c9ac245b43f3215f67f1f9710
|
data/lib/semantic_logger/base.rb
CHANGED
@@ -207,6 +207,10 @@ module SemanticLogger
|
|
207
207
|
SemanticLogger.tags
|
208
208
|
end
|
209
209
|
|
210
|
+
def named_tags
|
211
|
+
SemanticLogger.named_tags
|
212
|
+
end
|
213
|
+
|
210
214
|
# Returns the list of tags pushed after flattening them out and removing blanks
|
211
215
|
#
|
212
216
|
# Note:
|
@@ -301,13 +305,7 @@ module SemanticLogger
|
|
301
305
|
def filtered?(log)
|
302
306
|
return false if @filter.nil?
|
303
307
|
|
304
|
-
|
305
|
-
(@filter =~ log.name).nil?
|
306
|
-
elsif @filter.is_a?(Proc)
|
307
|
-
@filter.call(log) != true
|
308
|
-
else
|
309
|
-
raise(ArgumentError, "Unrecognized semantic logger filter: #{@filter.inspect}, must be a Regexp or a Proc")
|
310
|
-
end
|
308
|
+
@filter.is_a?(Regexp) ? (@filter =~ log.name).nil? : @filter.call(log) != true
|
311
309
|
end
|
312
310
|
|
313
311
|
# Ensure minimum log level is met
|
@@ -5,11 +5,7 @@ module SemanticLogger
|
|
5
5
|
def self.constantize_symbol(symbol, namespace = 'SemanticLogger::Appender')
|
6
6
|
klass = "#{namespace}::#{camelize(symbol.to_s)}"
|
7
7
|
begin
|
8
|
-
|
9
|
-
Object.const_get(klass)
|
10
|
-
else
|
11
|
-
klass.split('::').inject(Object) { |o, name| o.const_get(name) }
|
12
|
-
end
|
8
|
+
Object.const_get(klass)
|
13
9
|
rescue NameError
|
14
10
|
raise(ArgumentError, "Could not convert symbol: #{symbol.inspect} to a class in: #{namespace}. Looking for: #{klass}")
|
15
11
|
end
|
data/test/logger_test.rb
CHANGED
@@ -9,6 +9,13 @@ class LoggerTest < Minitest::Test
|
|
9
9
|
{action: 'hit', user: 'jbloggs', state: 'FL'}
|
10
10
|
end
|
11
11
|
|
12
|
+
# Complex filters
|
13
|
+
module ComplexFilter
|
14
|
+
def self.call(log)
|
15
|
+
(/\AExclude/ =~ log.message).nil?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
12
19
|
# Ensure that any log level can be logged
|
13
20
|
SemanticLogger::LEVELS.each do |level|
|
14
21
|
describe "##{level}" do
|
@@ -165,6 +172,13 @@ class LoggerTest < Minitest::Test
|
|
165
172
|
refute log_message
|
166
173
|
end
|
167
174
|
|
175
|
+
it 'Module' do
|
176
|
+
appender.filter = ComplexFilter
|
177
|
+
logger.send(level, 'Exclude this log message', @hash) { 'Calculations' }
|
178
|
+
|
179
|
+
refute log_message
|
180
|
+
end
|
181
|
+
|
168
182
|
it 'RegExp' do
|
169
183
|
filter = /\ALogger/
|
170
184
|
appender.filter = ->(log) { (/\AExclude/ =~ log.message).nil? }
|
@@ -182,6 +196,13 @@ class LoggerTest < Minitest::Test
|
|
182
196
|
refute log_message
|
183
197
|
end
|
184
198
|
|
199
|
+
it 'Module' do
|
200
|
+
logger.filter = ComplexFilter
|
201
|
+
logger.send(level, 'Exclude this log message', @hash) { 'Calculations' }
|
202
|
+
|
203
|
+
refute log_message
|
204
|
+
end
|
205
|
+
|
185
206
|
it 'RegExp' do
|
186
207
|
filter = /\ALogger/
|
187
208
|
logger.filter = ->(log) { (/\AExclude/ =~ log.message).nil? }
|
@@ -287,10 +308,13 @@ class LoggerTest < Minitest::Test
|
|
287
308
|
it 'also supports named tagging' do
|
288
309
|
logger.tagged(level1: 1) do
|
289
310
|
assert_equal({level1: 1}, SemanticLogger.named_tags)
|
311
|
+
assert_equal({level1: 1}, logger.named_tags)
|
290
312
|
logger.tagged(level2: 2, more: 'data') do
|
291
313
|
assert_equal({level1: 1, level2: 2, more: 'data'}, SemanticLogger.named_tags)
|
314
|
+
assert_equal({level1: 1, level2: 2, more: 'data'}, logger.named_tags)
|
292
315
|
logger.tagged(level3: 3) do
|
293
316
|
assert_equal({level1: 1, level2: 2, more: 'data', level3: 3}, SemanticLogger.named_tags)
|
317
|
+
assert_equal({level1: 1, level2: 2, more: 'data', level3: 3}, logger.named_tags)
|
294
318
|
end
|
295
319
|
end
|
296
320
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: semantic_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.3.
|
4
|
+
version: 4.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reid Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
version: '0'
|
141
141
|
requirements: []
|
142
142
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.7.
|
143
|
+
rubygems_version: 2.7.7
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: Feature rich logging framework, and replacement for existing Ruby & Rails
|