class Treequel::Loggable::ClassNameProxy

A logging proxy class that wraps calls to the logger into calls that include the name of the calling class.

Public Class Methods

new( klass, force_debug=false ) click to toggle source

Create a new proxy for the given klass.

# File lib/treequel/mixins.rb, line 157
def initialize( klass, force_debug=false )
        @classname   = klass.name
        @force_debug = force_debug
end

Public Instance Methods

debug( msg=nil, &block ) click to toggle source

Delegate debug messages to the global logger with the appropriate class name.

# File lib/treequel/mixins.rb, line 163
def debug( msg=nil, &block )
        Treequel.logger.add( Logger::DEBUG, msg, @classname, &block )
end
error( msg=nil, &block ) click to toggle source

Delegate error messages to the global logger with the appropriate class name.

# File lib/treequel/mixins.rb, line 180
def error( msg=nil, &block )
        return self.debug( msg, &block ) if @force_debug
        Treequel.logger.add( Logger::ERROR, msg, @classname, &block )
end
fatal( msg=nil, &block ) click to toggle source

Delegate fatal messages to the global logger with the appropriate class name.

# File lib/treequel/mixins.rb, line 186
def fatal( msg=nil, &block )
        Treequel.logger.add( Logger::FATAL, msg, @classname, &block )
end
info( msg=nil, &block ) click to toggle source

Delegate info messages to the global logger with the appropriate class name.

# File lib/treequel/mixins.rb, line 168
def info( msg=nil, &block )
        return self.debug( msg, &block ) if @force_debug
        Treequel.logger.add( Logger::INFO, msg, @classname, &block )
end
warn( msg=nil, &block ) click to toggle source

Delegate warn messages to the global logger with the appropriate class name.

# File lib/treequel/mixins.rb, line 174
def warn( msg=nil, &block )
        return self.debug( msg, &block ) if @force_debug
        Treequel.logger.add( Logger::WARN, msg, @classname, &block )
end