check if log can be written before trying it

This commit is contained in:
Steffen Schröder 2014-05-03 22:48:53 +02:00
parent f0a4fedfe1
commit 34390f9f12

View File

@ -82,11 +82,11 @@ function logMessage($message, $eol = true) {
$message .= PHP_EOL;
}
if (defined('LOG_CURRENT_FILE')) {
if (!file_put_contents(LOG_CURRENT_FILE, $message, FILE_APPEND)) {
echo 'Logfile not write-able, please check the File Permissions!';
if (!is_writable(dirname(LOG_CURRENT_FILE)) || !file_put_contents(LOG_CURRENT_FILE, $message, FILE_APPEND)) {
echo 'Current-Logfile not write-able, please check the File Permissions!';
}
}
if (!file_put_contents(LOG_FILE, $message, FILE_APPEND)) {
if (!is_writable(dirname(LOG_FILE)) || !file_put_contents(LOG_FILE, $message, FILE_APPEND)) {
echo 'Logfile not write-able, please check the File Permissions!';
}
echo $message;