Class LoggerRendererMap

Description

Log objects using customized renderers that implement LoggerRendererObject.

Example:

  1. require_once dirname(__FILE__).'/../../main/php/Logger.php';
  2. Logger::configure(dirname(__FILE__).'/../resources/renderer_map.properties');
  3.  
  4. class Person {
  5.     public $firstName 'John';
  6.     public $lastName 'Doe';
  7. }
  8.  
  9. class PersonRenderer implements LoggerRendererObject {
  10.     public function render($o{
  11.         return $o->lastName.', '.$o->firstName;
  12.     }
  13. }
  14.  
  15. $person new Person();
  16.  
  17. $logger Logger::getRootLogger();
  18. $logger->debug("Now comes the current Person object:");
  19. $logger->debug($person);

  1. log4php.renderer.Person = PersonRenderer
  2.  
  3. log4php.appender.default = LoggerAppenderEcho
  4. log4php.appender.default.layout = LoggerLayoutSimple
  5. log4php.rootLogger = DEBUG, default

 DEBUG - Now comes the current MyClass object:
 DEBUG - Doe, John

  • version: $Revision: 883108 $
  • since: 0.3

Located in /renderers/LoggerRendererMap.php (line 37)


	
			
Method Summary
static void addRenderer (string $renderedClassName, string $renderingClassName, LoggerHierarchy $repository)
LoggerRendererMap __construct ()
void clear ()
string findAndRender (mixed $o)
string getByObject (mixed $o)
Methods
static addRenderer (line 66)

Add a renderer to a hierarchy passed as parameter.

Note that hierarchy must implement getRendererMap() and setRenderer() methods.

  • access: public
static void addRenderer (string $renderedClassName, string $renderingClassName, LoggerHierarchy $repository)
  • LoggerHierarchy $repository: a logger repository.
  • string $renderedClassName
  • string $renderingClassName
Constructor __construct (line 52)

Constructor

  • access: public
LoggerRendererMap __construct ()
clear (line 137)
  • access: public
void clear ()
findAndRender (line 88)

Find the appropriate renderer for the class type of the o parameter.

This is accomplished by calling the getByObject() method if o is object or using LoggerRendererDefault. Once a renderer is found, it is applied on the object o and the result is returned as a string.

  • access: public
string findAndRender (mixed $o)
  • mixed $o
getByClassName (line 127)

Search the parents of clazz for a renderer.

The renderer closest in the hierarchy will be returned. If no renderers could be found, then the default renderer is returned.

  • access: public
LoggerRendererObject getByClassName (string $class)
  • string $class
getByObject (line 113)

Syntactic sugar method that calls http://www.php.net/get_class with the class of the object parameter.

  • access: public
string getByObject (mixed $o)
  • mixed $o

Documentation generated on Fri, 27 Nov 2009 07:44:52 +0100 by phpDocumentor 1.4.3