Module: RooOnRails::ContextLogging::Formatter

Defined in:
lib/roo_on_rails/context_logging.rb

Instance Method Summary collapse

Instance Method Details

#call(severity, timestamp, progname, msg) ⇒ Object



26
27
28
# File 'lib/roo_on_rails/context_logging.rb', line 26

def call(severity, timestamp, progname, msg)
  super(severity, timestamp, progname, "#{msg}#{context_text}")
end

#clear_context!Object



43
44
45
# File 'lib/roo_on_rails/context_logging.rb', line 43

def clear_context!
  current_context.clear
end

#with(**context) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/roo_on_rails/context_logging.rb', line 30

def with(**context)
  Thread.handle_interrupt(Exception => :never) do
    current_context.push(context)
    begin
      Thread.handle_interrupt(Exception => :immediate) do
        yield self
      end
    ensure
      current_context.pop
    end
  end
end