Loggability::Logger::

ObjectNameProxy class

Proxy for the Logger that injects the name of the object it wraps as the ‘progname’ of each log message.

Attributes

logger R

The Loggability::Logger this proxy is for.

progname R

The progname of the object the proxy is for.

Public Class Methods

new( logger, object )

Create a proxy for the given logger that will inject the name of the specified object into the ‘progname’ of each log message.

# File lib/loggability/logger.rb, line 32
def initialize( logger, object )
        @logger = logger
        @progname = make_progname( object )
end

Public Instance Methods

debug( msg=nil, &block )

Delegate debug messages

# File lib/loggability/logger.rb, line 49
def debug( msg=nil, &block )
        @logger.add( Logger::DEBUG, msg, @progname, &block )
end
error( msg=nil, &block )

Delegate error messages

# File lib/loggability/logger.rb, line 64
def error( msg=nil, &block )
        @logger.add( Logger::ERROR, msg, @progname, &block )
end
fatal( msg=nil, &block )

Delegate fatal messages

# File lib/loggability/logger.rb, line 69
def fatal( msg=nil, &block )
        @logger.add( Logger::FATAL, msg, @progname, &block )
end
info( msg=nil, &block )

Delegate info messages

# File lib/loggability/logger.rb, line 54
def info( msg=nil, &block )
        @logger.add( Logger::INFO, msg, @progname, &block )
end
inspect()

Return a human-readable string representation of the object, suitable for debugging.

# File lib/loggability/logger.rb, line 75
def inspect
        return "#<%p:%#016x for %s>" % [ self.class, self.object_id * 2, @progname ]
end
warn( msg=nil, &block )

Delegate warn messages

# File lib/loggability/logger.rb, line 59
def warn( msg=nil, &block )
        @logger.add( Logger::WARN, msg, @progname, &block )
end