From 6c39dcc9ec9436798f288d805c0c95aa77f08e9e Mon Sep 17 00:00:00 2001 From: George Dawoud Date: Sun, 2 Feb 2025 16:56:58 -0800 Subject: [PATCH] Only display error details if we are in debug more --- src/ChurchCRM/utils/LoggerUtils.php | 5 +++++ src/Include/slim/error-handler.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ChurchCRM/utils/LoggerUtils.php b/src/ChurchCRM/utils/LoggerUtils.php index 57b644cf27..d27add2055 100644 --- a/src/ChurchCRM/utils/LoggerUtils.php +++ b/src/ChurchCRM/utils/LoggerUtils.php @@ -32,6 +32,11 @@ public static function getLogLevel(): int return intval(SystemConfig::getValue('sLogLevel')); } + public static function isDebugLogLevel(): bool + { + return SystemConfig::getValue('sLogLevel') == Logger::DEBUG; + } + public static function buildLogFilePath(string $type): string { return SystemURLs::getDocumentRoot() . '/logs/' . date('Y-m-d') . '-' . $type . '.log'; diff --git a/src/Include/slim/error-handler.php b/src/Include/slim/error-handler.php index 424c9425c8..c9c0294fab 100644 --- a/src/Include/slim/error-handler.php +++ b/src/Include/slim/error-handler.php @@ -7,7 +7,7 @@ ini_set('log_errors', true); ini_set('error_log', LoggerUtils::buildLogFilePath('slim')); -$errorMiddleware = $app->addErrorMiddleware(true, true, true, LoggerUtils::getSlimMVCLogger()); +$errorMiddleware = $app->addErrorMiddleware(LoggerUtils::isDebugLogLevel(), true,true, LoggerUtils::getSlimMVCLogger()); // Get the default error handler and register my custom error renderer. $errorHandler = $errorMiddleware->getDefaultErrorHandler();