class Semlogr::LogContext

Public Class Methods

current() click to toggle source
# File lib/semlogr/log_context.rb, line 5
def self.current
  Thread.current[:semlogr_log_context] ||= []
end
get_property(key) click to toggle source
# File lib/semlogr/log_context.rb, line 17
def self.get_property(key)
  LogContext.current
    .reverse_each do |properties|
      return properties[key] if properties.key?(key)
    end

  nil
end
push_property(**properties) { || ... } click to toggle source
# File lib/semlogr/log_context.rb, line 9
def self.push_property(**properties)
  LogContext.current << properties

  yield if block_given?
ensure
  LogContext.current.pop
end