mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-02-24 23:08:08 +08:00
Cleanup Logger and bugfix its __phpErrorHandler
This commit is contained in:
parent
fa7ea413dc
commit
4e1722560f
2 changed files with 22 additions and 48 deletions
|
@ -17,41 +17,18 @@ namespace MailSo\Log;
|
|||
*/
|
||||
class Logger extends \MailSo\Base\Collection
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $bUsed;
|
||||
private $bUsed = false;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $aForbiddenTypes;
|
||||
private $aForbiddenTypes = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $aSecretWords;
|
||||
private $aSecretWords = [];
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $bShowSecter;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $bHideErrorNotices;
|
||||
private $bShowSecter = false;
|
||||
|
||||
function __construct(bool $bRegPhpErrorHandler = true)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->bUsed = false;
|
||||
$this->aForbiddenTypes = array();
|
||||
$this->aSecretWords = array();
|
||||
$this->bShowSecter = false;
|
||||
$this->bHideErrorNotices = false;
|
||||
|
||||
if ($bRegPhpErrorHandler)
|
||||
{
|
||||
\set_error_handler(array(&$this, '__phpErrorHandler'));
|
||||
|
@ -125,13 +102,7 @@ class Logger extends \MailSo\Base\Collection
|
|||
|
||||
public function SetShowSecter(bool $bShow) : self
|
||||
{
|
||||
$this->bShowSecter = !!$bShow;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function HideErrorNotices(bool $bValue) : self
|
||||
{
|
||||
$this->bHideErrorNotices = !!$bValue;
|
||||
$this->bShowSecter = $bShow;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -155,21 +126,23 @@ class Logger extends \MailSo\Base\Collection
|
|||
|
||||
public function __phpErrorHandler(int $iErrNo, string $sErrStr, string $sErrFile, int $iErrLine) : bool
|
||||
{
|
||||
$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;
|
||||
if (\error_reporting() & $iErrNo) {
|
||||
$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');
|
||||
}
|
||||
|
||||
$this->Write($sErrFile.' [line:'.$iErrLine.', code:'.$iErrNo.']', $iType, 'PHP');
|
||||
$this->Write('Error: '.$sErrStr, $iType, 'PHP');
|
||||
|
||||
return !!(\MailSo\Log\Enumerations\Type::NOTICE === $iType && $this->bHideErrorNotices);
|
||||
/* forward to standard PHP error handler */
|
||||
return false;
|
||||
}
|
||||
|
||||
public function __loggerShutDown() : void
|
||||
|
|
|
@ -30,6 +30,7 @@ class Service
|
|||
{
|
||||
\error_reporting(E_ALL);
|
||||
\ini_set('display_errors', 1);
|
||||
\ini_set('log_errors', 1);
|
||||
}
|
||||
|
||||
$sServer = \trim($this->oActions->Config()->Get('security', 'custom_server_signature', ''));
|
||||
|
|
Loading…
Reference in a new issue