From aa996693b5dcded865d653bcdfa9539d050f1802 Mon Sep 17 00:00:00 2001 From: John Flatness Date: Fri, 6 Sep 2024 17:57:17 -0400 Subject: [PATCH] Allow configuring log path Also change to just catching the Zend exception when trying to create the log on a non-writable file rather than checking writability explicitly. --- .../libraries/Omeka/Application/Resource/Logger.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/application/libraries/Omeka/Application/Resource/Logger.php b/application/libraries/Omeka/Application/Resource/Logger.php index 9527a490df..205dc46bd7 100644 --- a/application/libraries/Omeka/Application/Resource/Logger.php +++ b/application/libraries/Omeka/Application/Resource/Logger.php @@ -27,13 +27,17 @@ public function init() return; } - $logFile = LOGS_DIR . '/' . 'errors.log'; + if (empty($config->log->path)) { + $logFile = LOGS_DIR . '/' . 'errors.log'; + } else { + $logFile = $config->log->path; + } - if (!is_writable($logFile)) { + try { + $writer = new Zend_Log_Writer_Stream($logFile); + } catch (Zend_Log_Exception $e) { throw new RuntimeException('Error log file cannot be written to. Please give this file read/write permissions for the web server.'); } - - $writer = new Zend_Log_Writer_Stream($logFile); $logger = new Zend_Log($writer); if (isset($config->log->priority)) {