mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03: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
|
class Logger extends \MailSo\Base\Collection
|
||||||
{
|
{
|
||||||
/**
|
private $bUsed = false;
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
private $bUsed;
|
|
||||||
|
|
||||||
/**
|
private $aForbiddenTypes = [];
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private $aForbiddenTypes;
|
|
||||||
|
|
||||||
/**
|
private $aSecretWords = [];
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private $aSecretWords;
|
|
||||||
|
|
||||||
/**
|
private $bShowSecter = false;
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
private $bShowSecter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
private $bHideErrorNotices;
|
|
||||||
|
|
||||||
function __construct(bool $bRegPhpErrorHandler = true)
|
function __construct(bool $bRegPhpErrorHandler = true)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->bUsed = false;
|
|
||||||
$this->aForbiddenTypes = array();
|
|
||||||
$this->aSecretWords = array();
|
|
||||||
$this->bShowSecter = false;
|
|
||||||
$this->bHideErrorNotices = false;
|
|
||||||
|
|
||||||
if ($bRegPhpErrorHandler)
|
if ($bRegPhpErrorHandler)
|
||||||
{
|
{
|
||||||
\set_error_handler(array(&$this, '__phpErrorHandler'));
|
\set_error_handler(array(&$this, '__phpErrorHandler'));
|
||||||
|
|
@ -125,13 +102,7 @@ class Logger extends \MailSo\Base\Collection
|
||||||
|
|
||||||
public function SetShowSecter(bool $bShow) : self
|
public function SetShowSecter(bool $bShow) : self
|
||||||
{
|
{
|
||||||
$this->bShowSecter = !!$bShow;
|
$this->bShowSecter = $bShow;
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function HideErrorNotices(bool $bValue) : self
|
|
||||||
{
|
|
||||||
$this->bHideErrorNotices = !!$bValue;
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -155,6 +126,7 @@ class Logger extends \MailSo\Base\Collection
|
||||||
|
|
||||||
public function __phpErrorHandler(int $iErrNo, string $sErrStr, string $sErrFile, int $iErrLine) : bool
|
public function __phpErrorHandler(int $iErrNo, string $sErrStr, string $sErrFile, int $iErrLine) : bool
|
||||||
{
|
{
|
||||||
|
if (\error_reporting() & $iErrNo) {
|
||||||
$iType = \MailSo\Log\Enumerations\Type::NOTICE_PHP;
|
$iType = \MailSo\Log\Enumerations\Type::NOTICE_PHP;
|
||||||
switch ($iErrNo)
|
switch ($iErrNo)
|
||||||
{
|
{
|
||||||
|
|
@ -168,8 +140,9 @@ class Logger extends \MailSo\Base\Collection
|
||||||
|
|
||||||
$this->Write($sErrFile.' [line:'.$iErrLine.', code:'.$iErrNo.']', $iType, 'PHP');
|
$this->Write($sErrFile.' [line:'.$iErrLine.', code:'.$iErrNo.']', $iType, 'PHP');
|
||||||
$this->Write('Error: '.$sErrStr, $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
|
public function __loggerShutDown() : void
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ class Service
|
||||||
{
|
{
|
||||||
\error_reporting(E_ALL);
|
\error_reporting(E_ALL);
|
||||||
\ini_set('display_errors', 1);
|
\ini_set('display_errors', 1);
|
||||||
|
\ini_set('log_errors', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sServer = \trim($this->oActions->Config()->Get('security', 'custom_server_signature', ''));
|
$sServer = \trim($this->oActions->Config()->Get('security', 'custom_server_signature', ''));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue