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 +4 -4
- data/lib/contextual_logger/logger_with_context.rb +22 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d60e08b1b08501e772afba65533485b1f0ed81e
|
4
|
+
data.tar.gz: 67c440c0e671e2341a2fb5a4624327e75d7fb0b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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 =
|
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:)
|