lib/hornetq/common/log_delegate.rb in jruby-hornetq-0.2.5.alpha vs lib/hornetq/common/log_delegate.rb in jruby-hornetq-0.3.0.alpha
- old
+ new
@@ -2,13 +2,13 @@
# Internal use only class for delegating HornetQ logging into the Rails or Ruby
# loggers
#
private
- # HornetQ requires a factory from which it can create a logger per thread and/or class
+ # HornetQ requires a connection from which it can create a logger per thread and/or class
class LogDelegateFactory
- include
+ include Java::org.hornetq.spi.core.logging::LogDelegateFactory
def createDelegate(klass)
LogDelegate.new(klass.name)
end
end
@@ -22,25 +22,27 @@
@class_name = class_name
end
# DRY, generate a method for each required log level
['debug', 'error', 'fatal', 'info', 'trace', 'warn'].each do |level|
- eval <<-LOG_LEVEL_METHOD
- def #{level}(message)
- @logger.#{level}("[\#{@class_name}] \#{message}") if is#{level.capitalize}Enabled
- end
-
- def #{level}(message, t)
- if is#{level.capitalize}Enabled
- @logger.#{level}("[\#{@class_name}] \#{message}. \#{t.to_string}")
- @logger.#{level}(t.stack_trace.to_string)
+ eval <<LOG_LEVEL_METHOD
+ def #{level}(message, t=nil)
+ logger = HornetQ::logger
+ if logger.#{level}?
+ if t
+ logger.#{level}("[\#{@class_name}] \#{message}. \#{t.toString}")
+ logger.#{level}(t.stack_trace.toString)
+ else
+ logger.#{level}{"[\#{@class_name}] \#{message}"}
end
end
+ end
- def is#{level.capitalize}Enabled
- @logger.#{level}?
- end
- LOG_LEVEL_METHOD
+ def is#{level.capitalize}Enabled
+ HornetQ::logger.#{level}?
end
+LOG_LEVEL_METHOD
+ end
+
end
end
\ No newline at end of file