contextual_logger 1.2.0.colin.2 → 1.2.0.colin.4

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: fa81557c8d0035dc91b9285be3a429b5c3bef9d27842f62306a827b3a842d284
4
- data.tar.gz: f63ece3db1c77acda0f05ea7af4dc581aefff65bb62464977a8b9a645090fe9f
3
+ metadata.gz: 7b8180f031cfc4c1facc22a0cfbbadf8970b01a1b7c1d18f974dbf54fd1712d5
4
+ data.tar.gz: d310df13569303aa5f6964d1cf9f73583fcfcabcd5950f330b00a30f8eb151f5
5
5
  SHA512:
6
- metadata.gz: 5dbfc7e625e0b8e9b7111371da8368194d8d628192f91955cc98807fb0e8ecc67e10473137c1333513376d233c112a990c8fe8e5506741322995433c4f75f62f
7
- data.tar.gz: 966f798d247c5cadaa32e2269830153f7280e0ad015554db4f065c7a5f5729f5f39b3f443dde6f8f4659797da218ede4af320ac278723651099c2e8f2495e877
6
+ metadata.gz: e0c0350c9f36cf27071a7e1da1f42363979852304c4b029ca24d0a550c77bfb403815dc09420d5c8d9c164b003f8a22213e5d33216e1647ae63143a3b73447e9
7
+ data.tar.gz: 4984642ce8b36e78c3f14f0415ac95d67dec97f9f5651f6c63deb715bbfa27134243f7286e09802146b6629df0bc1077c476ea3e3d5ad783779daa718aef032d
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ContextualLogger
4
- VERSION = '1.2.0.colin.2'
4
+ VERSION = '1.2.0.colin.4'
5
5
  end
@@ -56,22 +56,25 @@ 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
+ # TODO: Deprecate current_context_for_thread in v2.0.
64
+ alias current_context_for_thread current_context
65
+
63
66
  def with_context(context)
64
- previous_context = current_context_for_thread
65
- self.current_context = previous_context.deep_merge(context)
67
+ previous_context_override = current_context_override
68
+ self.current_context_override = current_context.deep_merge(context)
66
69
  if block_given?
67
70
  begin
68
71
  yield
69
72
  ensure
70
- self.current_context = previous_context
73
+ self.current_context_override = previous_context_override
71
74
  end
72
75
  else
73
76
  # If no block given, return context handler to the caller so they can call reset! themselves.
74
- ContextHandler.new(self, previous_context)
77
+ ContextHandler.new(self, previous_context_override)
75
78
  end
76
79
  end
77
80
 
@@ -124,7 +127,7 @@ module ContextualLogger
124
127
  message = arg1
125
128
  progname = arg2 || @progname
126
129
  end
127
- write_entry_to_log(severity, Time.now, progname, message, context: current_context_for_thread.deep_merge(context))
130
+ write_entry_to_log(severity, Time.now, progname, message, context: current_context.deep_merge(context))
128
131
  end
129
132
 
130
133
  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.2
4
+ version: 1.2.0.colin.4
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-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json