/[cvs]/nfo/php/libs/net.php.pear/Log/observer.php
ViewVC logotype

Contents of /nfo/php/libs/net.php.pear/Log/observer.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Fri Oct 25 15:15:23 2002 UTC (21 years, 8 months ago) by cvsjoko
Branch: MAIN
+ generic logging mechanism via PEAR::Log

1 <?php
2 // $Horde: horde/lib/Log/observer.php,v 1.5 2000/06/28 21:36:13 jon Exp $
3
4 /**
5 * The Log_observer:: class implements the Observer end of a
6 * Subject-Observer pattern for watching log activity and taking
7 * actions on exceptional events.
8 *
9 * @author Chuck Hagenbuch <chuck@horde.org>
10 * @version $Revision: 1.1 $
11 * @since Horde 1.3
12 */
13 class Log_observer {
14
15 // {{{ properties
16
17 /** The minimum priority level of message that we want to hear
18 about. 0 (LOG_EMERG) is the highest priority, so we will only
19 hear messages with an integer priority value less than or
20 equal to ours. It defaults to LOG_INFO, which listens to
21 everything except LOG_DEBUG. */
22 var $priority = LOG_INFO;
23
24 // }}}
25
26
27 // {{{ constructor
28 /**
29 * Basic Log_observer instance that just prints out messages
30 * received.
31 */
32 function Log_observer ($priority = LOG_INFO) {
33 $this->priority = $priority;
34 }
35 // }}}
36
37
38 // {{{ factory()
39 /**
40 * Attempts to return a concrete Log_observer instance of the
41 * specified type.
42 *
43 * @param $observer_type The type of concrate Log_observer subclass
44 * to return. We will attempt to dynamically
45 * include the code for this subclass.
46 * @return The newly created concrete Log_observer
47 * instance, or an false on an error. */
48 function factory ($observer_type, $priority = LOG_INFO) {
49 $classfile = substr(__FILE__, 0, -(strlen(basename(__FILE__)))) . 'Log/' . $observer_type . '.php';
50 if (file_exists($classfile)) {
51 include_once $classfile;
52 $class = 'Log_' . $observer_type;
53 return new $observer_type($priority);
54 } else {
55 return false;
56 }
57 }
58 // }}}
59
60 // {{{ notify()
61 /**
62 * This is a stub method to make sure that LogObserver classes do
63 * something when they are notified of a message. The default
64 * behavior is to just print the message, which is obviously not
65 * desireable in practically any situation - which is why you need
66 * to override this method. :)
67 *
68 * @param $messageOb A hash containing all information - the text
69 * message itself, the priority, what log it came
70 * from, etc.
71 */
72 function notify ($messageOb) {
73 print_r($messageOb);
74 }
75 // }}}
76
77 }
78
79 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed