mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 08:27:03 +03:00
Filter improvements
This commit is contained in:
parent
f91f74fe7c
commit
05b1c1dfe5
14 changed files with 222 additions and 68 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue