A logging proxy class that wraps calls to the logger into calls that include the name of the calling class.
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
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
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
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
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
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