Filter improvements

This commit is contained in:
RainLoop Team 2015-05-13 02:53:01 +04:00
parent f91f74fe7c
commit 05b1c1dfe5
14 changed files with 222 additions and 68 deletions

View file

@ -47,6 +47,11 @@ abstract class Driver
*/
protected $bTypedPrefix;
/**
* @var string
*/
protected $sNewLine;
/**
* @var int
*/
@ -79,6 +84,7 @@ abstract class Driver
{
$this->sDatePattern = 'H:i:s';
$this->sName = 'INFO';
$this->sNewLine = "\r\n";
$this->bTimePrefix = true;
$this->bTypedPrefix = true;
$this->bGuidPrefix = true;
@ -246,15 +252,44 @@ abstract class Driver
return isset($this->aPrefixes[$iType]) ? $sName.$this->aPrefixes[$iType].': ' : '';
}
/**
* @param string|array $mDesc
* @param bool $bDiplayCrLf = false
*
* @return string
*/
protected function localWriteImplementation($mDesc, $bDiplayCrLf = false)
{
if ($bDiplayCrLf)
{
if (\is_array($mDesc))
{
foreach ($mDesc as &$sLine)
{
$sLine = \strtr($sLine, array("\r" => '\r', "\n" => '\n'.$this->sNewLine));
$sLine = \rtrim($mDesc);
}
}
else
{
$mDesc = \strtr($mDesc, array("\r" => '\r', "\n" => '\n'.$this->sNewLine));
$mDesc = \rtrim($mDesc);
}
}
return $this->writeImplementation($mDesc);
}
/**
* @final
* @param string $sDesc
* @param int $iType = \MailSo\Log\Enumerations\Type::INFO
* @param string $sName = ''
* @param bool $bDiplayCrLf = false
*
* @return bool
*/
final public function Write($sDesc, $iType = \MailSo\Log\Enumerations\Type::INFO, $sName = '')
final public function Write($sDesc, $iType = \MailSo\Log\Enumerations\Type::INFO, $sName = '', $bDiplayCrLf = false)
{
$bResult = true;
if (!$this->bFlushCache && ($this->bWriteOnErrorOnly || $this->bWriteOnPhpErrorOnly || 0 < $this->iWriteOnTimeoutOnly))
@ -285,18 +320,18 @@ abstract class Driver
if (isset($this->aCache[0]) && empty($this->aCache[0]))
{
$this->aCache[0] = $sFlush;
array_unshift($this->aCache, '');
\array_unshift($this->aCache, '');
}
else
{
array_unshift($this->aCache, $sFlush);
\array_unshift($this->aCache, $sFlush);
}
$this->aCache[] = '--- FlushLogCache: Trigger';
$this->aCache[] = $this->loggerLineImplementation($this->getTimeWithMicroSec(), $sDesc, $iType, $sName);
$this->bFlushCache = true;
$bResult = $this->writeImplementation($this->aCache);
$bResult = $this->localWriteImplementation($this->aCache, $bDiplayCrLf);
$this->aCache = array();
}
else if (0 < $this->iWriteOnTimeoutOnly && \time() - APP_START_TIME > $this->iWriteOnTimeoutOnly)
@ -305,18 +340,18 @@ abstract class Driver
if (isset($this->aCache[0]) && empty($this->aCache[0]))
{
$this->aCache[0] = $sFlush;
array_unshift($this->aCache, '');
\array_unshift($this->aCache, '');
}
else
{
array_unshift($this->aCache, $sFlush);
\array_unshift($this->aCache, $sFlush);
}
$this->aCache[] = '--- FlushLogCache: Trigger';
$this->aCache[] = $this->loggerLineImplementation($this->getTimeWithMicroSec(), $sDesc, $iType, $sName);
$this->bFlushCache = true;
$bResult = $this->writeImplementation($this->aCache);
$bResult = $this->localWriteImplementation($this->aCache, $bDiplayCrLf);
$this->aCache = array();
}
else
@ -326,13 +361,21 @@ abstract class Driver
}
else
{
$bResult = $this->writeImplementation(
$this->loggerLineImplementation($this->getTimeWithMicroSec(), $sDesc, $iType, $sName));
$bResult = $this->localWriteImplementation(
$this->loggerLineImplementation($this->getTimeWithMicroSec(), $sDesc, $iType, $sName), $bDiplayCrLf);
}
return $bResult;
}
/**
* @return string
*/
public function GetNewLine()
{
return $this->sNewLine;
}
/**
* @final
* @return bool