Added MailSo\Log\Enumerations\Type::DEBUG

This commit is contained in:
the-djmaze 2022-04-18 20:36:07 +02:00
parent 710659560b
commit e80b1825eb
3 changed files with 20 additions and 22 deletions

View file

@ -100,6 +100,7 @@ abstract class Driver
$this->aCache = array();
$this->aPrefixes = array(
\MailSo\Log\Enumerations\Type::DEBUG => '[DEBUG]',
\MailSo\Log\Enumerations\Type::INFO => '[DATA]',
\MailSo\Log\Enumerations\Type::SECURE => '[SECURE]',
\MailSo\Log\Enumerations\Type::NOTE => '[NOTE]',
@ -152,12 +153,7 @@ abstract class Driver
public function WriteOnTimeoutOnly(int $iTimeout) : self
{
$this->iWriteOnTimeoutOnly = (int) $iTimeout;
if (0 > $this->iWriteOnTimeoutOnly)
{
$this->iWriteOnTimeoutOnly = 0;
}
$this->iWriteOnTimeoutOnly = \max(0, (int) $iTimeout);
return $this;
}
@ -225,7 +221,7 @@ abstract class Driver
final public function Write(string $sDesc, int $iType = \MailSo\Log\Enumerations\Type::INFO, string $sName = '', bool $bDiplayCrLf = false)
{
$bResult = true;
if (!$this->bFlushCache && ($this->bWriteOnErrorOnly || $this->bWriteOnPhpErrorOnly || 0 < $this->iWriteOnTimeoutOnly))
if (!$this->bFlushCache && ($this->bWriteOnErrorOnly || $this->bWriteOnPhpErrorOnly || $this->iWriteOnTimeoutOnly))
{
$bErrorPhp = false;
@ -267,7 +263,7 @@ abstract class Driver
$bResult = $this->localWriteImplementation($this->aCache, $bDiplayCrLf);
$this->aCache = array();
}
else if (0 < $this->iWriteOnTimeoutOnly && \time() - $_SERVER['REQUEST_TIME_FLOAT'] > $this->iWriteOnTimeoutOnly)
else if ($this->iWriteOnTimeoutOnly && \time() - $_SERVER['REQUEST_TIME_FLOAT'] > $this->iWriteOnTimeoutOnly)
{
$sFlush = '--- FlushLogCache: WriteOnTimeoutOnly ['.(\time() - $_SERVER['REQUEST_TIME_FLOAT']).'sec]';
if (isset($this->aCache[0]) && empty($this->aCache[0]))
@ -313,7 +309,7 @@ abstract class Driver
final public function WriteEmptyLine() : void
{
if (!$this->bFlushCache && ($this->bWriteOnErrorOnly || $this->bWriteOnPhpErrorOnly || 0 < $this->iWriteOnTimeoutOnly))
if (!$this->bFlushCache && ($this->bWriteOnErrorOnly || $this->bWriteOnPhpErrorOnly || $this->iWriteOnTimeoutOnly))
{
$this->aCache[] = '';
}

View file

@ -18,17 +18,19 @@ namespace MailSo\Log\Enumerations;
*/
abstract class Type
{
const INFO = 0;
const NOTICE = 1;
const WARNING = 2;
const ERROR = 3;
const SECURE = 4;
const NOTE = 5;
const TIME = 6;
const MEMORY = 7;
const TIME_DELTA = 8;
const
INFO = 0,
NOTICE = 1,
WARNING = 2,
ERROR = 3,
SECURE = 4,
NOTE = 5,
TIME = 6,
MEMORY = 7,
TIME_DELTA = 8,
DEBUG = 9,
const NOTICE_PHP = 11;
const WARNING_PHP = 12;
const ERROR_PHP = 13;
NOTICE_PHP = 11,
WARNING_PHP = 12,
ERROR_PHP = 13;
}

View file

@ -44,7 +44,7 @@ abstract class Log
\LOG_WARNING => Type::WARNING,
\LOG_NOTICE => Type::NOTICE,
\LOG_INFO => Type::INFO,
\LOG_DEBUG => Type::INFO
\LOG_DEBUG => Type::DEBUG
];
protected static function log(int $level, string $prefix, string $msg)