Module: Dry::Logger::ExecutionContext Private

Defined in:
lib/dry/logger/execution_context.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Provides isolated thread-local storage for logger values.

Constant Summary collapse

CONTEXT_KEY =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

:__dry_logger__

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a value from the current execution context.

Parameters:

  • key (Symbol)

    the key to retrieve

Returns:

  • (Object, nil)

    the stored value, or nil if no value has been stored



17
18
19
# File 'lib/dry/logger/execution_context.rb', line 17

def [](key)
  context[key]
end

.[]=(key, value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Sets a value in the current execution context.

Parameters:

  • key (Symbol)

    the key to store

  • value (Object)

    the value to store

Returns:

  • (Object)

    the stored value



27
28
29
# File 'lib/dry/logger/execution_context.rb', line 27

def []=(key, value)
  context[key] = value
end

.clearself

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Clears all values from the current execution context.

Returns:

  • (self)


34
35
36
37
# File 'lib/dry/logger/execution_context.rb', line 34

def clear
  current_store[CONTEXT_KEY] = {}
  self
end