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