module Epilog::ContextFormatter

Public Instance Methods

context() click to toggle source
# File lib/epilog/context_logging.rb, line 22
def context
  Thread.current[current_context_key] ||= begin
    result = {}
    context_stack.each { |frame| result.merge!(frame) }
    result
  end.freeze
end
pop_context() click to toggle source
# File lib/epilog/context_logging.rb, line 35
def pop_context
  clear_context
  context_stack.pop
end
push_context(frame) click to toggle source
# File lib/epilog/context_logging.rb, line 30
def push_context(frame)
  clear_context
  context_stack.push(frame)
end

Private Instance Methods

clear_context() click to toggle source
# File lib/epilog/context_logging.rb, line 42
def clear_context
  Thread.current[current_context_key] = nil
end
context_stack() click to toggle source
# File lib/epilog/context_logging.rb, line 46
def context_stack
  Thread.current[stack_key] ||= []
end
current_context_key() click to toggle source
# File lib/epilog/context_logging.rb, line 54
def current_context_key
  @current_context_key ||= "epilog_context_current:#{object_id}"
end
stack_key() click to toggle source
# File lib/epilog/context_logging.rb, line 50
def stack_key
  @stack_key ||= "epilog_context_stack:#{object_id}"
end