Class: DRbService::Logging::ClassNameProxy
- Inherits:
-
Object
- Object
- DRbService::Logging::ClassNameProxy
- 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
-
#initialize(klass, force_debug = false) ⇒ ClassNameProxy
constructor
Create a new proxy for the given
klass
. -
#method_missing(sym, msg = nil, &block) ⇒ Object
Delegate calls the global logger with the class name as the ‘progname’ argument.
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 |