Skip to content

Commit

Permalink
Allow configuring log path
Browse files Browse the repository at this point in the history
Also change to just catching the Zend exception when trying to create
the log on a non-writable file rather than checking writability
explicitly.
  • Loading branch information
zerocrates committed Sep 6, 2024
1 parent 375e6c3 commit aa99669
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions application/libraries/Omeka/Application/Resource/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit aa99669

Please sign in to comment.