contextual_logger 1.2.0.colin.1 → 1.2.0.colin.3

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: 68939d6780d99c6d6a266aa6bcf10c4d457b27bb34bf2dc06b8faacf26aec1bd
4
- data.tar.gz: c90bc720ec41a2d61a177243c815c109f16d631db1251ea03497d80bd2b6e22e
3
+ metadata.gz: 7bd0747cf5faa06b9907d60198830c374f83f226df121efa9a0b7049315f9132
4
+ data.tar.gz: 808bbac948431f55a8f4a07532884f3ed310a63652c536512aa5dd435454c6fb
5
5
  SHA512:
6
- metadata.gz: a86dbe5c5f407d2affc7a4a58e237e0b61cb36db5dceb33db62bf3e01cb94e5f4e9863a3ac79765c02e5bb02d682246a854a71d5c102d390f1b6cb759faf5d79
7
- data.tar.gz: 7376b31fbb12bce7a87f506a3c2f0ad89a5fe92c925cd9b469f176195ecfe21fa235a2a168ca9fcd43a42e7c7db7a56649aa5d02fa3d430ccc1108e710aa0ab7
6
+ metadata.gz: f3607fbfd8f6ddbc8b3b29943fd4787c16509997262b2d3ae309d41471d013da89ef76585d804775721ce1ac9fe75260a9eaf356ffee1cacc9bf2fc65ed4b273
7
+ data.tar.gz: 3e929c9f55c3bd12a1b65ba3e5135c1e56f5dc87b1597b3a6da9adfcc038f47bd0b8e2a01f9b6d294bfca549d681bef8a9cf67482771e6e4d0aa1db6d86e137b
@@ -7,12 +7,12 @@ module ContextualLogger
7
7
  @thread_context_for_logger_instance ||= "ContextualLogger::Context.context_for_#{object_id}".to_sym
8
8
  end
9
9
 
10
- def current_context
10
+ def current_context_override
11
11
  Thread.current[thread_context_for_logger_instance]
12
12
  end
13
13
 
14
- def current_context=(context)
15
- Thread.current[thread_context_for_logger_instance] = context.freeze
14
+ def current_context_override=(context_override)
15
+ Thread.current[thread_context_for_logger_instance] = context_override.freeze
16
16
  end
17
17
  end
18
18
  end
@@ -2,13 +2,13 @@
2
2
 
3
3
  module ContextualLogger
4
4
  class ContextHandler
5
- def initialize(instance, previous_context)
5
+ def initialize(instance, previous_context_override)
6
6
  @instance = instance
7
- @previous_context = previous_context
7
+ @previous_context_override = previous_context_override
8
8
  end
9
9
 
10
10
  def reset!
11
- @instance.current_context = @previous_context
11
+ @instance.current_context_override = @previous_context_override
12
12
  end
13
13
  end
14
14
  end
@@ -19,6 +19,10 @@ module ContextualLogger
19
19
  @merged_context_cache = {} # so we don't have to merge every time
20
20
  end
21
21
 
22
+ def global_context
23
+ @logger.global_context
24
+ end
25
+
22
26
  def level
23
27
  @override_level || @logger.level
24
28
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ContextualLogger
4
- VERSION = '1.2.0.colin.1'
4
+ VERSION = '1.2.0.colin.3'
5
5
  end
@@ -56,22 +56,22 @@ module ContextualLogger
56
56
  @global_context = context.freeze
57
57
  end
58
58
 
59
- def current_context_for_thread
60
- current_context || global_context
59
+ def current_context
60
+ current_context_override || global_context
61
61
  end
62
62
 
63
63
  def with_context(context)
64
- previous_context = current_context_for_thread
65
- self.current_context = previous_context.deep_merge(context)
64
+ previous_context_override = current_context_override
65
+ self.current_context_override = current_context.deep_merge(context)
66
66
  if block_given?
67
67
  begin
68
68
  yield
69
69
  ensure
70
- self.current_context = previous_context
70
+ self.current_context_override = previous_context_override
71
71
  end
72
72
  else
73
73
  # If no block given, return context handler to the caller so they can call reset! themselves.
74
- ContextHandler.new(self, previous_context)
74
+ ContextHandler.new(self, previous_context_override)
75
75
  end
76
76
  end
77
77
 
@@ -124,7 +124,7 @@ module ContextualLogger
124
124
  message = arg1
125
125
  progname = arg2 || @progname
126
126
  end
127
- write_entry_to_log(severity, Time.now, progname, message, context: current_context_for_thread.deep_merge(context))
127
+ write_entry_to_log(severity, Time.now, progname, message, context: current_context.deep_merge(context))
128
128
  end
129
129
 
130
130
  true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contextual_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.colin.1
4
+ version: 1.2.0.colin.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Ebentier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-31 00:00:00.000000000 Z
11
+ date: 2023-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json