Sha256: 21f038b5fe2e5a98c4cb8cd0406c35d3c343577d66940330716d9b9c63fb269d

Contents?: true

Size: 1.23 KB

Versions: 5

Compression:

Stored size: 1.23 KB

Contents

# Extend HornetQ Logger class to respond to standard Rails/Ruby log methods
#
# The following methods are already implemented by the java class
#   initialize
#   delegate
#
# The following methods are being replaced so that they can support blocks
#   trace
#   debug
#   info
#   warn
#   error
#   fatal
#
# The following methods are new
#   trace?
#   debug?
#   info?
#   warn?
#   error?
#   fatal?
#

# This has to be a "mix-in" because the class can return instances of itself
class org.hornetq.core.logging::Logger
  # DRY, generate a method for each required log level
  ['debug', 'error', 'fatal', 'info', 'trace', 'warn'].each do |level|
    eval <<LOG_LEVEL_METHOD
  def #{level}?
    #{level}_enabled?
  end

  alias :java_#{level} :#{level}

  # Support logging with block parameters that only get evaluated if the
  # matching log level is enabled
  def #{level}(message=nil, &block)
    if #{level}?
      if block
        java_#{level}(block.call.to_s.to_java_string)
      else
        java_#{level}(message.to_s.to_java_string)
      end
    end
  end
LOG_LEVEL_METHOD
  end

  private
  # Implement since not implemented by Logger
  def error_enabled?
    true
  end
  def fatal_enabled?
    true
  end
  def warn_enabled?
    true
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jruby-hornetq-0.4.0 lib/hornetq/common/org_hornetq_core_logging_logger.rb
jruby-hornetq-0.3.3 lib/hornetq/common/org_hornetq_core_logging_logger.rb
jruby-hornetq-0.3.2 lib/hornetq/common/org_hornetq_core_logging_logger.rb
jruby-hornetq-0.3.1 lib/hornetq/common/org_hornetq_core_logging_logger.rb
jruby-hornetq-0.3.0.alpha lib/hornetq/common/org_hornetq_core_logging_logger.rb