cvs: php4 /pear/Log observer.php
| From: | Chuck Hagenbuch | Date: | Fri, 10 Aug 2001 18:47:54 +0000 |
| Subject: | cvs: php4 /pear/Log observer.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-461@lists.php.net to get a copy of this message | ||
chagenbu Fri Aug 10 14:47:54 2001 EDT
Modified files:
/php4/pear/Log observer.php
Log:
clean up some of this. More changes coming at some point.
Index: php4/pear/Log/observer.php
diff -u php4/pear/Log/observer.php:1.1 php4/pear/Log/observer.php:1.2
--- php4/pear/Log/observer.php:1.1 Wed Dec 6 20:06:58 2000
+++ php4/pear/Log/observer.php Fri Aug 10 14:47:54 2001
@@ -4,10 +4,10 @@
/**
* The Log_observer:: class implements the Observer end of a
* Subject-Observer pattern for watching log activity and taking
- * actions on exceptional events.
+ * actions when notable events occur.
*
* @author Chuck Hagenbuch <chuck@horde.org>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
* @since Horde 1.3
*/
class Log_observer {
@@ -46,20 +46,32 @@
* @return The newly created concrete Log_observer
* instance, or an false on an error. */
function factory ($observer_type, $priority = LOG_INFO) {
- $classfile = substr(__FILE__, 0, -(strlen(basename(__FILE__)))) . 'Log/' .
$observer_type . '.php';
- if (file_exists($classfile)) {
- include_once $classfile;
- $class = 'Log_' . $observer_type;
- return new $observer_type($priority);
- } else {
- return false;
+ if (empty($observer_type)) {
+ return new Log_observer($priority);
}
+
+ $observer_type = strtolower(basename($observer_type));
+ $class = 'Log_observer_' . $observer_type;
+ if (class_exists($class)) {
+ // The observer subclass has already been defined.
+ return new $class($priority);
+ }
+
+ $classfile = 'Log/' . $observer_type . '.php';
+ @include_once $classfile;
+ if (class_exists($class)) {
+ // We found the class definition somewhere in the include_path.
+ return new $class($priority);
+ }
+
+ // We failed to find the class definition anywhere. Return false.
+ return false;
}
// }}}
// {{{ notify()
/**
- * This is a stub method to make sure that LogObserver classes do
+ * This is a stub method to make sure that Log_observer classes do
* something when they are notified of a message. The default
* behavior is to just print the message, which is obviously not
* desireable in practically any situation - which is why you need