<?php/** * File contains strictly only Logger decorator class. * * The logger decorator allows using PEAR classes with {@link Logger}. * More information there : {@link LoggingDecorator} * There goes the credits : * <ul> * <li>Shrike@irc.freenode.net:##php (decorator pattern demonstration)</li> * <li>f00li5h@irc.freenode.net:##php</li> * </ul> * Thank you for having shared your time and experience ! * @author James PIC <is_null@devangels.org> * @copyright James PIC * @version 1.0 * @package Logger *//** * Decarotar to Logging API. * <p>This is a decorator class, this means that you should use it * when you instanciate a PEAR object.</p> * <p>For example :</p> * <code> * // used in {@inline eMail()} * $mail_object =& new LoggingDecorator( Mail::factory('mail') ); * $cool_object =& new LoggingDecorator( new Cool ); * // then objects can be used normally, pear errors will be redireted to Logger * </code> * @author James PIC <is_null@devangels.org> * @copyright James PIC * @version 1.0 * @uses Logger */class LoggingDecorator{/** * The actual object to decorate with {@inline Logger}. * @access private * @var object */ private $o_decorated; public function __construct($o_decorated) { $this->o_decorated = $o_decorated; } public function __call($s_method, $a_arguments) { $ret = call_user_func_array(array($this->o_decorated, $s_method), $a_arguments); if($ret instanceof PEAR_Error) { $i = 0; while (!@strpos($ret->backtrace[$i]['file'], 'loggingdecorator.class.php') && @$ret->backtrace[$i]['function'] != 'call_user_func_array') { $i++; } $a_last_event = $ret->backtrace[--$i]; Logger::GetInstance()->Log($a_arguments, $a_last_event['class'].'::'.$s_method, (int)@$a_last_event['line'], $ret->message, 'error', false); Logger::GetInstance()->ShowLog(); } }}?>