diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Log/Inherit.php b/snappymail/v/0.0.0/app/libraries/MailSo/Log/Inherit.php index a82d0b2a0..64cef9825 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Log/Inherit.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Log/Inherit.php @@ -29,10 +29,9 @@ trait Inherit $this->oLogger = $oLogger; } - public function logWrite(string $sDesc, int $iType = \LOG_INFO, - string $sName = '', bool $bSearchSecretWords = true, bool $bDiplayCrLf = false): bool + public function logWrite(string $sDesc, int $iType = \LOG_INFO, string $sName = '', bool $bDiplayCrLf = false): bool { - return $this->oLogger && $this->oLogger->Write($sDesc, $iType, $sName, $bSearchSecretWords, $bDiplayCrLf); + return $this->oLogger && $this->oLogger->Write($sDesc, $iType, $sName, $bDiplayCrLf); } public function logException(\Throwable $oException, int $iType = \LOG_NOTICE, string $sName = ''): void diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Log/Logger.php b/snappymail/v/0.0.0/app/libraries/MailSo/Log/Logger.php index f6aa4f608..58bd3c2d4 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Log/Logger.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Log/Logger.php @@ -112,11 +112,12 @@ class Logger extends \SplFixedArray string $sWord ) : void { -// $this->bShowSecrets && $this->Write("AddSecret '{$sWord}'", \LOG_INFO, '', false); +// $this->bShowSecrets && $this->Write("AddSecret '{$sWord}'", \LOG_INFO); $sWord = \trim($sWord); if (\strlen($sWord)) { $this->aSecretWords[] = $sWord; $this->aSecretWords = \array_unique($this->aSecretWords); + \usort($this->aSecretWords, fn($a,$b) => \strlen($b) - \strlen($a)); } } @@ -220,8 +221,7 @@ class Logger extends \SplFixedArray } } - public function Write(string $sDesc, int $iType = \LOG_INFO, - string $sName = '', bool $bSearchSecretWords = true, bool $bDiplayCrLf = false) : bool + public function Write(string $sDesc, int $iType = \LOG_INFO, string $sName = '', bool $bDiplayCrLf = false) : bool { if ($this->iLevel < $iType) { return true; @@ -229,7 +229,7 @@ class Logger extends \SplFixedArray $this->bUsed = true; - if ($bSearchSecretWords && !$this->bShowSecrets && $this->aSecretWords) { + if (!$this->bShowSecrets && $this->aSecretWords) { $sDesc = \str_replace($this->aSecretWords, '*******', $sDesc); } diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Pdo/Base.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Pdo/Base.php index 2becb01ff..8de393fe7 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Pdo/Base.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Pdo/Base.php @@ -187,9 +187,9 @@ abstract class Base { if ($this->oLogger) { if ($mData instanceof \Throwable) { - $this->oLogger->WriteException($mData, \LOG_ERR, 'SQL'); + $this->logException($mData, \LOG_ERR, 'SQL'); } else if (\is_scalar($mData)) { - $this->oLogger->Write((string) $mData, \LOG_INFO, 'SQL'); + $this->logWrite((string) $mData, \LOG_INFO, 'SQL'); } else { $this->oLogger->WriteDump($mData, \LOG_INFO, 'SQL'); } diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php b/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php index b868f6519..762bf9bf3 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php @@ -110,7 +110,7 @@ class ServiceActions $sMethodName = 'Do'.$sAction; - $this->Logger()->Write('Action: '.$sMethodName, \LOG_INFO, 'JSON'); + $this->oActions->logWrite('Action: '.$sMethodName, \LOG_INFO, 'JSON'); $aPost = $_POST ?? null; if ($aPost) { @@ -130,7 +130,7 @@ class ServiceActions break; } */ - $this->Logger()->Write(Utils::jsonEncode($aPost), \LOG_INFO, 'POST'); + $this->oActions->logWrite(Utils::jsonEncode($aPost), \LOG_INFO, 'POST'); } else if (3 < \count($this->aPaths) && $this->oHttp->IsGet()) { $this->oActions->SetActionParams(array( 'RawKey' => empty($this->aPaths[3]) ? '' : $this->aPaths[3] @@ -184,15 +184,15 @@ class ServiceActions if ($this->Logger()->IsEnabled()) { if (\strlen($sObResult)) { - $this->Logger()->Write($sObResult, \LOG_ERR, 'OB-DATA'); + $this->oActions->logWrite($sObResult, \LOG_ERR, 'OB-DATA'); } if ($oException) { - $this->Logger()->WriteException($oException, \LOG_ERR); + $this->oActions->logException($oException, \LOG_ERR); } $iLimit = (int) $this->Config()->Get('labs', 'log_ajax_response_write_limit', 0); - $this->Logger()->Write(0 < $iLimit && $iLimit < \strlen($sResult) + $this->oActions->logWrite(0 < $iLimit && $iLimit < \strlen($sResult) ? \substr($sResult, 0, $iLimit).'...' : $sResult, \LOG_INFO, 'JSON'); } @@ -252,10 +252,10 @@ class ServiceActions $sObResult = \ob_get_clean(); if (\strlen($sObResult)) { - $this->Logger()->Write($sObResult, \LOG_ERR, 'OB-DATA'); + $this->oActions->logWrite($sObResult, \LOG_ERR, 'OB-DATA'); } - $this->Logger()->Write($sResult, \LOG_INFO, 'UPLOAD'); + $this->oActions->logWrite($sResult, \LOG_INFO, 'UPLOAD'); return $sResult; } @@ -369,12 +369,12 @@ class ServiceActions } if (\strlen($sRawError)) { - $this->Logger()->Write($sRawError, \LOG_ERR); + $this->oActions->logWrite($sRawError, \LOG_ERR); $this->Logger()->WriteDump($this->aPaths, \LOG_ERR, 'PATHS'); } if ($oException) { - $this->Logger()->WriteException($oException, \LOG_ERR, 'RAW'); + $this->oActions->logException($oException, \LOG_ERR, 'RAW'); } return $sResult; @@ -481,7 +481,7 @@ class ServiceActions } catch (\Throwable $oException) { - $this->Logger()->WriteException($oException, \LOG_ERR, 'LESS'); + $this->oActions->logException($oException, \LOG_ERR, 'LESS'); } } @@ -526,7 +526,7 @@ class ServiceActions $this->oHttp->ServerNoCache(); \header('Content-Type: text/plain; charset=utf-8'); - $this->oActions->Logger()->Write('Pong', \LOG_INFO, 'PING'); + $this->oActions->logWrite('Pong', \LOG_INFO, 'PING'); return 'Pong'; } @@ -598,7 +598,7 @@ class ServiceActions } catch (\Throwable $oException) { - $this->Logger()->WriteException($oException); + $this->oActions->logException($oException); } } } @@ -632,7 +632,7 @@ class ServiceActions $this->oHttp->ServerNoCache(); try { $sResult = Utils::jsonEncode($this->oActions->AppData($bAdmin)); - $this->Logger()->Write($sResult, \LOG_INFO, 'APPDATA'); + $this->oActions->logWrite($sResult, \LOG_INFO, 'APPDATA'); return $sResult; } catch (\Throwable $oException) { $this->Logger()->WriteExceptionShort($oException);