Class: TorqueBox::Logger

Inherits:
Object
  • Object
show all
Defined in:
core/lib/torquebox/logger.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Logger) initialize(name = nil)

A new instance of Logger



47
48
49
50
# File 'core/lib/torquebox/logger.rb', line 47

def initialize name = nil
  category = name || (TORQUEBOX_APP_NAME if defined? TORQUEBOX_APP_NAME) || "TorqueBox"
  @logger = org.jboss.logging::Logger.getLogger( category.to_s.gsub('::','.') )
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(method, *args, &block)



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'core/lib/torquebox/logger.rb', line 58

def method_missing(method, *args, &block)
  delegate = method
  if method.to_s.end_with?('?')
    delegate = "#{method.to_s.chop}_enabled?".to_sym
  end
  self.class.class_eval do
    define_method(method) do |*a, &b|
      params = [ a[0] || (b && b.call) ].compact
      @logger.send(delegate, *params)
    end
  end
  self.send(method, *args, &block)
end

Instance Attribute Details

- (Object) level

Returns the value of attribute level



56
57
58
# File 'core/lib/torquebox/logger.rb', line 56

def level
  @level
end