X-Git-Url: https://git.cweiske.de/auerswald-callnotifier.git/blobdiff_plain/04c3f73883fbd8621044599f0286ccc781ae1c79..1d01023d44f2d338b8bbcd28f0830ce813c2595d:/src/callnotifier/Logger/CallFileTop.php diff --git a/src/callnotifier/Logger/CallFileTop.php b/src/callnotifier/Logger/CallFileTop.php index 4dc6b6c..fca02ab 100644 --- a/src/callnotifier/Logger/CallFileTop.php +++ b/src/callnotifier/Logger/CallFileTop.php @@ -18,7 +18,7 @@ class Logger_CallFileTop extends Logger_CallBase protected $file; /** - * Create a new file call logger. + * Create a new file call logger. * * @param string $file Path to the file to log the calls in. * @param string $callTypes Which types of call to log: @@ -67,8 +67,13 @@ class Logger_CallFileTop extends Logger_CallBase if (isset($arLines[0]) && $arLines[0] == $date) { //same date as previous log entry $arLines = array_pad($arLines, -count($arLines) - 1, ''); - } else { + } else if (!isset($arLines[0])) { + //empty file $arLines = array_pad($arLines, -count($arLines) - 2, ''); + } else { + //new date + $arLines = array_pad($arLines, -count($arLines) - 3, ''); + $arLines[2] = "\n"; } $arLines[0] = $date; $arLines[1] = $logline; @@ -85,9 +90,18 @@ class Logger_CallFileTop extends Logger_CallBase $this->addUnsetVars($call); $str = ' ' . date('H:i', $call->start); if ($call->type == CallMonitor_Call::INCOMING) { - $str .= ' von ' . str_pad($this->getNumberString($call, 'from'), 30); + $prefix = ' von '; + $numstr = $this->getNumberString($call, 'from'); + } else { + $prefix = ' nach '; + $numstr = $this->getNumberString($call, 'to'); + } + + if ($this->callTypes == 'io') { + $str .= $prefix; + $str .= Functions::mb_str_pad($numstr, 20); } else { - $str .= ' nach ' . str_pad($this->getNumberString($call, 'to'), 30); + $str .= ' ' . Functions::mb_str_pad($numstr, 25); } $str .= ' ' . date('H:i:s', $call->end - $call->start - 3600);