Added "write_on_php_error_only" setting

This commit is contained in:
RainLoop Team 2014-09-03 23:53:24 +04:00
parent 9bf5847983
commit 9bde3fe5dd
7 changed files with 125 additions and 61 deletions

View file

@ -28,6 +28,11 @@ class Logger extends \MailSo\Base\Collection
*/
private $bShowSecter;
/**
* @var bool
*/
private $bHideErrorNotices;
/**
* @access protected
*/
@ -39,7 +44,9 @@ class Logger extends \MailSo\Base\Collection
$this->aForbiddenTypes = array();
$this->aSecretWords = array();
$this->bShowSecter = false;
$this->bHideErrorNotices = false;
\set_error_handler(array(&$this, '__phpErrorHandler'));
\register_shutdown_function(array(&$this, '__loggerShutDown'));
}
@ -83,6 +90,14 @@ class Logger extends \MailSo\Base\Collection
return $sCache;
}
/**
* @return bool
*/
public function Ping()
{
return true;
}
/**
* @return bool
*/
@ -107,13 +122,23 @@ class Logger extends \MailSo\Base\Collection
/**
* @param bool $bShow
*
*
* @return \MailSo\Log\Logger
*/
public function SetShowSecter($bShow)
{
$this->bShowSecter = !!$bShow;
return $this;
}
/**
* @param bool $bValue
*
* @return \MailSo\Log\Logger
*/
public function HideErrorNotices($bValue)
{
$this->bHideErrorNotices = !!$bValue;
return $this;
}
@ -145,10 +170,36 @@ class Logger extends \MailSo\Base\Collection
public function RemoveForbiddenType($iType)
{
$this->aForbiddenTypes[$iType] = false;
return $this;
}
/**
* @param int $iErrNo
* @param string $sErrStr
* @param string $sErrFile
* @param int $iErrLine
*
* @return bool
*/
public function __phpErrorHandler($iErrNo, $sErrStr, $sErrFile, $iErrLine)
{
$iType = \MailSo\Log\Enumerations\Type::NOTICE_PHP;
switch ($iErrNo)
{
case E_USER_ERROR:
$iType = \MailSo\Log\Enumerations\Type::ERROR_PHP;
break;
case E_USER_WARNING:
$iType = \MailSo\Log\Enumerations\Type::WARNING_PHP;
break;
}
$this->Write($sErrFile.' [line:'.$iErrLine.', code:'.$iErrNo.']', $iType, 'PHP');
$this->Write('Error: '.$sErrStr, $iType, 'PHP');
return !!(\MailSo\Log\Enumerations\Type::NOTICE === $iType && $this->bHideErrorNotices);
}
/**
* @return void
*/
@ -164,7 +215,7 @@ class Logger extends \MailSo\Base\Collection
$this->Write('Memory peak usage: '.$aStatistic['php']['memory_get_peak_usage'],
\MailSo\Log\Enumerations\Type::MEMORY);
}
if (isset($aStatistic['time']))
{
$this->Write('Time delta: '.$aStatistic['time'], \MailSo\Log\Enumerations\Type::TIME_DELTA);
@ -179,7 +230,7 @@ class Logger extends \MailSo\Base\Collection
public function WriteEmptyLine()
{
$iResult = 1;
$aLoggers =& $this->GetAsArray();
foreach ($aLoggers as /* @var $oLogger \MailSo\Log\Driver */ &$oLogger)
{