Class: Log4jruby::Log4jArgs

Inherits:
Object
  • Object
show all
Defined in:
lib/log4jruby/log4j_args.rb

Class Method Summary collapse

Class Method Details

.convert(object = nil, exception = nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/log4jruby/log4j_args.rb', line 4

def convert(object = nil, exception = nil)
  msg = ''

  if exception
    msg << object.to_s
  else
    exception = block_given? ? yield : object
  end

  if exception.is_a?(NativeException)
    append_ruby_error(msg, exception)
    msg << "\nNativeException:"
    exception = exception.cause
  elsif exception.is_a?(::Exception)
    append_ruby_error(msg, exception)
    exception = nil
  elsif !exception.is_a?(java.lang.Throwable)
    msg << exception.to_s
    exception = nil
  end

  [msg, exception]
end