Module: FluQ::Mixins::Logger

Defined in:
lib/fluq/mixins/logger.rb

Instance Method Summary collapse

Instance Method Details

#crash(string, exception) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fluq/mixins/logger.rb', line 11

def crash(string, exception)
  if exception.respond_to?(:backtrace) && exception.backtrace
    trace = exception.backtrace.map {|line| "  #{line}" }.join("\n")
  end
  error [string, trace].compact.join("\n")

  exception_handlers.each do |handler|
    begin
      handler.call(exception)
    rescue => ex
      error "EXCEPTION HANDLER CRASHED: #{ex.message}"
    end
  end
end

#exception_handler(&block) ⇒ Object



7
8
9
# File 'lib/fluq/mixins/logger.rb', line 7

def exception_handler(&block)
  exception_handlers << block
end

#exception_handlersObject



3
4
5
# File 'lib/fluq/mixins/logger.rb', line 3

def exception_handlers
  @exception_handlers ||= []
end