From 96493efb7db724bf8fefc1d027b45917efaebf4d Mon Sep 17 00:00:00 2001 From: ashraf Date: Tue, 14 May 2024 16:34:55 +0200 Subject: [PATCH] OXDEV-7785 Log level --- .../Configuration/Dao/SystemConfigurationDao.php | 1 + .../Configuration/DataObject/SystemConfiguration.php | 12 ++++++++++++ source/Internal/Transition/Utility/BasicContext.php | 2 +- source/Internal/Transition/Utility/Context.php | 5 ++--- source/config.inc.php.dist | 5 ----- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/source/Internal/Framework/Configuration/Dao/SystemConfigurationDao.php b/source/Internal/Framework/Configuration/Dao/SystemConfigurationDao.php index 714016ecae7..b4383c7c05d 100644 --- a/source/Internal/Framework/Configuration/Dao/SystemConfigurationDao.php +++ b/source/Internal/Framework/Configuration/Dao/SystemConfigurationDao.php @@ -21,6 +21,7 @@ public function get(): SystemConfiguration $systemConfiguration->setDatabaseUrl(getenv('OXID_DB_URL')); $systemConfiguration->setShopDirectory(getenv('OXID_SHOP_DIRECTORY')); $systemConfiguration->setCompilationDirectory(getenv('OXID_COMPILATION_DIRECTORY')); + $systemConfiguration->setLogLevel(getenv('OXID_LOG_LEVEL')); return $systemConfiguration; } diff --git a/source/Internal/Framework/Configuration/DataObject/SystemConfiguration.php b/source/Internal/Framework/Configuration/DataObject/SystemConfiguration.php index 8b143fc3750..d4c00740ae0 100644 --- a/source/Internal/Framework/Configuration/DataObject/SystemConfiguration.php +++ b/source/Internal/Framework/Configuration/DataObject/SystemConfiguration.php @@ -15,6 +15,8 @@ class SystemConfiguration private string $shopDirectory; private string $compilationDirectory; + private string $logLevel; + public function getDatabaseUrl(): string { return $this->databaseUrl; @@ -44,4 +46,14 @@ public function setCompilationDirectory(string $compilationDirectory): void { $this->compilationDirectory = $compilationDirectory; } + + public function getLogLevel(): string + { + return $this->logLevel; + } + + public function setLogLevel(string $logLevel): void + { + $this->logLevel = $logLevel; + } } diff --git a/source/Internal/Transition/Utility/BasicContext.php b/source/Internal/Transition/Utility/BasicContext.php index bb07431bde6..038288d78f9 100644 --- a/source/Internal/Transition/Utility/BasicContext.php +++ b/source/Internal/Transition/Utility/BasicContext.php @@ -32,7 +32,7 @@ class BasicContext implements BasicContextInterface */ private $facts; - private SystemConfiguration $systemConfiguration; + protected SystemConfiguration $systemConfiguration; public function __construct() { diff --git a/source/Internal/Transition/Utility/Context.php b/source/Internal/Transition/Utility/Context.php index b6be7fa2a59..2dc005cf977 100644 --- a/source/Internal/Transition/Utility/Context.php +++ b/source/Internal/Transition/Utility/Context.php @@ -14,7 +14,6 @@ use OxidEsales\Eshop\Core\FileCache; use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\ShopIdCalculator; -use OxidEsales\EshopCommunity\Core\Di\ContainerFacade; use OxidEsales\EshopCommunity\Internal\Framework\Database\BootstrapConnectionFactory; use OxidEsales\EshopCommunity\Internal\Transition\Utility\Exception\AdminUserNotFoundException; use OxidEsales\Facts\Config\ConfigFile as FactsConfigFile; @@ -34,7 +33,7 @@ class Context extends BasicContext implements ContextInterface */ public function getLogLevel(): string { - return $this->getFactsConfigFile()->getVar('sLogLevel') ?? LogLevel::ERROR; + return $this->systemConfiguration->getLogLevel() ?? LogLevel::ERROR; } /** @@ -42,7 +41,7 @@ public function getLogLevel(): string */ public function getLogFilePath(): string { - return Path::join(ContainerFacade::getParameter('oxid_shop_directory'), 'log', 'oxideshop.log'); + return Path::join($this->getSourcePath(), 'log', 'oxideshop.log'); } /** diff --git a/source/config.inc.php.dist b/source/config.inc.php.dist index d25825cf2a5..af825af4a95 100755 --- a/source/config.inc.php.dist +++ b/source/config.inc.php.dist @@ -21,11 +21,6 @@ $this->aAllowedUploadTypes = array('jpg', 'gif', 'png', 'pdf', 'mp3', 'avi', 'mp // Timezone information date_default_timezone_set('Europe/Berlin'); -/** - * String PSR3 log level Psr\Log\LogLevel - */ -$this->sLogLevel = 'error'; - /** * Log all modifications performed in Admin */