cvs: php4 /pear Log.php

From: Date: Tue, 06 Nov 2001 21:46:41 +0000
Subject: cvs: php4 /pear Log.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-1274@lists.php.net to get a copy of this message
chagenbu Tue Nov 6 16:46:41 2001 EDT Modified files: /php4/pear Log.php Log: fix the singleton and factory methods for a). php 4.0.6 (where include_once might return false) b). to use references and not copy so many objects Index: php4/pear/Log.php diff -u php4/pear/Log.php:1.2 php4/pear/Log.php:1.3 --- php4/pear/Log.php:1.2 Thu Jan 4 10:56:05 2001 +++ php4/pear/Log.php Tue Nov 6 16:46:41 2001 @@ -1,5 +1,5 @@ <?php -// $Id: Log.php,v 1.2 2001/01/04 15:56:05 chagenbu Exp $ +// $Id: Log.php,v 1.3 2001/11/06 21:46:41 chagenbu Exp $ // $Horde: horde/lib/Log.php,v 1.15 2000/06/29 23:39:45 jon Exp $ /** @@ -8,7 +8,7 @@ * * @author Chuck Hagenbuch <chuck@horde.org> * @author Jon Parise <jon@csh.rit.edu> - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * @since Horde 1.3 */ class Log { @@ -51,11 +51,13 @@ * @return The newly created concrete Log instance, or an * false on an error. */ - function factory ($log_type, $log_name = '', $ident = '', $conf = array()) { + function &factory($log_type, $log_name = '', $ident = '', $conf = array()) + { $log_type = strtolower($log_type); $classfile = 'Log/' . $log_type . '.php'; - if (@include_once $classfile) { - $class = 'Log_' . $log_type; + @include_once $classfile; + $class = 'Log_' . $log_type; + if (class_exists($class)) { return new $class($log_name, $ident, $conf); } else { return false; @@ -101,7 +103,7 @@ $signature = md5($log_type . '][' . $log_name . '][' . $ident . '][' . implode('][', $conf)); if (!isset($instances[$signature])) { - $instances[$signature] = Log::factory($log_type, $log_name, $ident, $conf); + $instances[$signature] = &Log::factory($log_type, $log_name, $ident, $conf); } return $instances[$signature]; }

« previous php.pear.cvs (#1274) next »