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

View file

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

View file

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