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: 951b7e0fc762a3801a11ccf9d3ca9cc503742453f39490ddd41112895d677fe7
4
- data.tar.gz: 25c47bbee6b929b1f23fcc56ee6f34164066af52fb130ff238877d833538cb62
3
+ metadata.gz: 285869f2b402ea378eab2606d3d72f7b7be3db56102bea2c530a98411a077d6c
4
+ data.tar.gz: cab30b7d7bcfda6083716a530aeedf20192b1fa1c3a83c7cb237d475516d0ca7
5
5
  SHA512:
6
- metadata.gz: 9553643ca1faf2f9d124cd05333f648f4770f1249a46ec92c21b2cb41856d9d0ee62d65cb59bf097548a10b22f91b6530fe48a2138ecdca5ee997e69fd4da3ca
7
- data.tar.gz: 25e1949848b10937692ea12fbab2d83a090c36c09cc9a005cc64a4263b8838cba9d712e628bd4f311b58ac6b416963ae759609864935faaf0efdc73501cd397c
6
+ metadata.gz: e67d39bfbedb72f64b191f75d5786f521d311d78fb243bb97cbfa948333fcfa21f89ebcfa6a9ac34696a24c359bd8b67a9617228a25a1958bbf3092ed6324472
7
+ data.tar.gz: c446a8410247e2b8393f401182f0bc1a266d329ce1190328a3f7253bf5b64273c87c5db05a4bb4f808caf9435b0e8a8d2a37a69c9ac245b43f3215f67f1f9710
@@ -127,7 +127,7 @@ module SemanticLogger
127
127
  message: h.delete(:message),
128
128
  event: h
129
129
  }
130
- message[:source_type] = source_type if source_type
130
+ message[:sourcetype] = source_type if source_type
131
131
  message
132
132
  end
133
133
  end
@@ -96,7 +96,7 @@ module SemanticLogger
96
96
  time: h.delete(:time),
97
97
  event: h
98
98
  }
99
- message[:source_type] = source_type if source_type
99
+ message[:sourcetype] = source_type if source_type
100
100
  message[:index] = index if index
101
101
  message.to_json
102
102
  end
@@ -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
- if @filter.is_a?(Regexp)
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
- if RUBY_VERSION.to_i >= 2
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
@@ -1,3 +1,3 @@
1
1
  module SemanticLogger
2
- VERSION = '4.3.0'.freeze
2
+ VERSION = '4.3.1'.freeze
3
3
  end
@@ -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.0
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-05-07 00:00:00.000000000 Z
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.6
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