contextual_logger 0.4.pre.1 → 0.4.pre.2

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: 6fd7d8ae966a768ad95020d9dacf6c60a6abc938
4
- data.tar.gz: 5251c5e24e99820875dbf83b01dc7ae9390c9ed8
3
+ metadata.gz: 6d60e08b1b08501e772afba65533485b1f0ed81e
4
+ data.tar.gz: 67c440c0e671e2341a2fb5a4624327e75d7fb0b5
5
5
  SHA512:
6
- metadata.gz: a0d4e12220c89308677cd1195ec942780d57f11ddab574f11f4fe6a5a6615852cc8f5973f17b99b1fcba9f2c25c953f1bb3492220903b7f5d729f66851d344e9
7
- data.tar.gz: baca8317383cf92cc6d9572287877ec42989638af1774465d506e63062125593e7a3dc610779ac564b4175a9ff6e866fc5ca592b2fd94b8ea5d244c737ae1624
6
+ metadata.gz: f562cb98eb0b24e0315d8ee7e77913797d996e9fe2df5a67f520d2c20e8c507bad05ce9ab888a5e7757d4f7857d3f80c13a2740eff9503002b4435e8ad85df35
7
+ data.tar.gz: 530f4febd3444df313d9e98742df89d1dafcfa5083c6a39ba92aad586819fadaf3c4e574b21fa42ed9edb62f4c42dc70869f67f2e838e9d25838d4a1c14deaba
@@ -12,7 +12,7 @@ module ContextualLogger
12
12
  def initialize(logger, context, level: nil)
13
13
  logger.is_a?(LoggerMixin) or raise ArgumentError, "logger must include ContextualLogger::LoggerMixin (got #{logger.inspect})"
14
14
  @logger = logger
15
- @override_level = level
15
+ self.level = level
16
16
  @context = context
17
17
  @merged_context_cache = {} # so we don't have to merge every time
18
18
  end
@@ -22,7 +22,27 @@ module ContextualLogger
22
22
  end
23
23
 
24
24
  def level=(override_level)
25
- @override_level = override_level
25
+ @override_level =
26
+ if (Logger::Severity::DEBUG..Logger::Severity::UNKNOWN).include?(override_level) || override_level.nil?
27
+ override_level
28
+ else
29
+ case override_level.to_s.downcase
30
+ when 'debug'
31
+ Logger::Severity::DEBUG
32
+ when 'info'
33
+ Logger::Severity::INFO
34
+ when 'warn'
35
+ Logger::Severity::WARN
36
+ when 'error'
37
+ Logger::Severity::ERROR
38
+ when 'fatal'
39
+ Logger::Severity::FATAL
40
+ when 'unknown'
41
+ Logger::Severity::UNKNOWN
42
+ else
43
+ raise ArgumentError, "invalid log level: #{override_level.inspect}"
44
+ end
45
+ end
26
46
  end
27
47
 
28
48
  def write_entry_to_log(severity, timestamp, progname, message, context:)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contextual_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.pre.1
4
+ version: 0.4.pre.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Ebentier