2 namespace callnotifier;
4 class Logger_CallFile extends Logger_CallBase
10 * Create a new file call logger. It logs finished calls into a file.
12 * @param string $file Path to the file to log the calls in.
13 * @param string $callTypes Which types of call to log:
14 * - "i" - incoming calls only
15 * - "o" - outgoing calls only
16 * - "io" - both incoming and outgoing calls
17 * @param array $msns Array of MSN (Multi Subscriber Number) that
18 * calls to shall get logged.
19 * If the array is empty, calls to all MSNs get
22 public function __construct(
28 $this->callTypes = $callTypes;
29 $this->msns = (array)$msns;
31 $this->fileHdl = fopen($this->file, 'a');
32 if (!$this->fileHdl) {
34 'Cannot open call log file for writing: ' . $this->file
39 public function log($type, $arData)
41 if ($type != 'finishedCall') {
45 $call = $arData['call'];
46 if (!$this->hasValidType($call)) {
49 if (!$this->hasValidMsn($call)) {
53 fwrite($this->fileHdl, $this->createLogEntry($call));
57 protected function createLogEntry(CallMonitor_Call $call)
59 $this->addUnsetVars($call);
60 $str = date('Y-m-d H:i:s', $call->start);
61 if ($call->type == CallMonitor_Call::INCOMING) {
62 $str .= ' ' . $call->to
63 . ' von ' . $this->getNumberString($call, 'from');
65 $str .= ' ' . $call->from
66 . ' nach ' . $this->getNumberString($call, 'to');
69 $str .= ', Dauer ' . date('H:i:s', $call->end - $call->start - 3600);