contextual_logger 0.4.0 → 0.5.0

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: 245a6e7a65a43e18414fe3bfca78aeda87493f17
4
- data.tar.gz: 63f6b2f7e58251d49072606976db9c2ce8c0e021
3
+ metadata.gz: 2982d6e312ab94acc9d71c3ed92d127f3c52c1cb
4
+ data.tar.gz: 031bc0dc6c086dbbb8f3795db550514814482b38
5
5
  SHA512:
6
- metadata.gz: df61515ebf5df8bbea58efe09b4d04d597c9649abb4bd56ba4c3dff4473ab53a1b95062fb6babd0e509233b27c08c1906551492c973966d9aa92e35408e7307e
7
- data.tar.gz: 357fd36aa25e68af5895c230355338dc996b2f81b0c0c3b42843f32f9c20e83b3c98f02a0fd7776977d49c2a23be18c08cb8f6d6d838aef359c12a9eaef73248
6
+ metadata.gz: 0c07df2056f512b6190f6aee23911f0da948c9625e89b4c0acb0d2449713c84eaa468c4cd20964e2bdf3790b178cff23ccbf8818536a20b01ba41c57c1f1f6f4
7
+ data.tar.gz: c91b9641c769391a31209725ad60b2b375c89e60f337c59118cbbf092cd291a23cbceed321e9caf6acf35c3dab898c19c220a473ed3abe351758b73bcea9b43a
@@ -9,6 +9,29 @@ module ContextualLogger
9
9
  def new(logger)
10
10
  logger.extend(LoggerMixin)
11
11
  end
12
+
13
+ def normalize_log_level(log_level)
14
+ if log_level.is_a?(Integer) && (Logger::Severity::DEBUG..Logger::Severity::UNKNOWN).include?(log_level)
15
+ log_level
16
+ else
17
+ case log_level.to_s.downcase
18
+ when 'debug'
19
+ Logger::Severity::DEBUG
20
+ when 'info'
21
+ Logger::Severity::INFO
22
+ when 'warn'
23
+ Logger::Severity::WARN
24
+ when 'error'
25
+ Logger::Severity::ERROR
26
+ when 'fatal'
27
+ Logger::Severity::FATAL
28
+ when 'unknown'
29
+ Logger::Severity::UNKNOWN
30
+ else
31
+ raise ArgumentError, "invalid log level: #{log_level.inspect}"
32
+ end
33
+ end
34
+ end
12
35
  end
13
36
 
14
37
  module LoggerMixin
@@ -22,27 +22,7 @@ module ContextualLogger
22
22
  end
23
23
 
24
24
  def 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
25
+ @override_level = (ContextualLogger.normalize_log_level(override_level) if override_level)
46
26
  end
47
27
 
48
28
  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.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Ebentier