Improved logging

Small fixes
This commit is contained in:
RainLoop Team 2014-06-06 20:11:38 +04:00
parent 187e44607d
commit 6c28b24aaf
11 changed files with 301 additions and 246 deletions

View file

@ -23,6 +23,11 @@ abstract class Driver
*/
protected $aPrefixes;
/**
* @var bool
*/
protected $bGuidPrefix;
/**
* @var bool
*/
@ -62,6 +67,7 @@ abstract class Driver
$this->sName = 'INFO';
$this->bTimePrefix = true;
$this->bTypedPrefix = true;
$this->bGuidPrefix = true;
$this->iWriteOnTimeoutOnly = 0;
$this->bWriteOnErrorOnly = false;
@ -80,6 +86,15 @@ abstract class Driver
);
}
/**
* @return \MailSo\Log\Driver
*/
public function DisableGuidPrefix()
{
$this->bGuidPrefix = false;
return $this;
}
/**
* @return \MailSo\Log\Driver
*/
@ -150,9 +165,11 @@ abstract class Driver
protected function loggerLineImplementation($sTimePrefix, $sDesc,
$iType = \MailSo\Log\Enumerations\Type::INFO, $sName = '')
{
return ($this->bTimePrefix ? '['.$sTimePrefix.'] ' : '').
($this->bTypedPrefix ? $this->getTypedPrefix($iType, $sName) : '').
$sDesc;
return \ltrim(
($this->bTimePrefix ? '['.$sTimePrefix.']' : '').
($this->bGuidPrefix ? '['.\MailSo\Log\Logger::Guid().']' : '').
($this->bTypedPrefix ? ' '.$this->getTypedPrefix($iType, $sName) : '')
).$sDesc;
}
/**
@ -215,6 +232,7 @@ abstract class Driver
array_unshift($this->aCache, $sFlush);
}
$this->aCache[] = '--- FlushLogCache: Trigger';
$this->aCache[] = $this->loggerLineImplementation($this->getTimeWithMicroSec(), $sDesc, $iType, $sName);
$this->bFlushCache = true;
@ -234,6 +252,7 @@ abstract class Driver
array_unshift($this->aCache, $sFlush);
}
$this->aCache[] = '--- FlushLogCache: Trigger';
$this->aCache[] = $this->loggerLineImplementation($this->getTimeWithMicroSec(), $sDesc, $iType, $sName);
$this->bFlushCache = true;