blob: 8a6b79a9ada81bd2c03766218c0e99243ed8dc20 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
<?php
namespace callnotifier;
class Log
{
/**
* Array of logger object arrays.
* Key is the notification type, value is an array of logger objects
* that want to get notified about the type.
*
* @var array
*/
protected $logger = array(
'msgData' => array(),
'edss1msg' => array(),
'incomingCall' => array(),
'finishedCall' => array(),
);
/**
* Add a logger
*
* @param Logger $logger Logger object to register
* @param array|string $types Single notification type or array of such
* types. "*" means "register for all types".
*
* @return self
*/
public function addLogger(Logger $logger, $types)
{
if ($types == '*') {
$types = array_keys($this->logger);
}
$types = (array)$types;
foreach ($types as $type) {
if (!isset($this->logger[$type])) {
throw new \Exception('Unknown log type: ' . $type);
}
$this->logger[$type][] = $logger;
}
}
public function log($type, $arData)
{
if (!isset($this->logger[$type])) {
throw new \Exception('Unknown log type: ' . $type);
}
if (count($this->logger[$type])) {
foreach ($this->logger[$type] as $logger) {
$logger->log($type, $arData);
}
}
}
}
?>
|