Class: DRbService::Logging::ClassNameProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/drbservice/utils.rb

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(klass, force_debug = false) ⇒ ClassNameProxy

Create a new proxy for the given klass.



387
388
389
390
# File 'lib/drbservice/utils.rb', line 387

def initialize( klass, force_debug=false )
	@classname   = klass.name
	@force_debug = force_debug
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, msg = nil, &block) ⇒ Object

Delegate calls the global logger with the class name as the ‘progname’ argument.



394
395
396
397
398
# File 'lib/drbservice/utils.rb', line 394

def method_missing( sym, msg=nil, &block )
	return super unless LEVEL.key?( sym )
	sym = :debug if @force_debug
	DRbService.logger.add( LEVEL[sym], msg, @classname, &block )
end