Module: Lumberjack::ContextLocals

Included in:
Lumberjack
Defined in:
lib/lumberjack/context_locals.rb

Overview

Provides isolated fiber or thread local storage for thread-safe data access.

Defined Under Namespace

Classes: Data

Instance Method Summary collapse

Instance Method Details

#isolation_levelSymbol

Get the isolation level for context locals.

Returns:

  • (Symbol)

    The isolation level, either :fiber or :thread.



32
33
34
# File 'lib/lumberjack/context_locals.rb', line 32

def isolation_level
  @isolation_level ||= :fiber
end

#isolation_level=(value) ⇒ void

This method returns an undefined value.

Set the isolation level for context locals.

Parameters:

  • value (Symbol)

    The isolation level, either :fiber or :thread.



23
24
25
26
27
# File 'lib/lumberjack/context_locals.rb', line 23

def isolation_level=(value)
  value = value&.to_sym
  value = :fiber unless [:fiber, :thread].include?(value)
  @isolation_level = value
end