2 namespace callnotifier;
9 * Array of logger object arrays.
10 * Key is the notification type, value is an array of logger objects
11 * that want to get notified about the type.
15 protected $logger = array(
17 'edss1msg' => array(),
18 'startingCall' => array(),
19 'finishedCall' => array(),
25 * @param Logger $logger Logger object to register
26 * @param array|string $types Single notification type or array of such
27 * types. "*" means "register for all types".
31 public function addLogger(Logger $logger, $types)
34 $types = array_keys($this->logger);
36 $types = (array)$types;
39 $logger->debug = $this->debug;
42 foreach ($types as $type) {
43 if (!isset($this->logger[$type])) {
44 throw new \Exception('Unknown log type: ' . $type);
46 $this->logger[$type][] = $logger;
50 public function log($type, $arData)
52 if (!isset($this->logger[$type])) {
53 throw new \Exception('Unknown log type: ' . $type);
56 if (count($this->logger[$type])) {
57 foreach ($this->logger[$type] as $logger) {
59 echo "Logging to " . get_class($logger) . "\n";
61 $logger->log($type, $arData);