]> source.dussan.org Git - nextcloud-server.git/commitdiff
Try to create custom log file before falling back to default.
authorAndreas Fischer <bantu@owncloud.com>
Sun, 20 Oct 2013 21:58:07 +0000 (23:58 +0200)
committerAndreas Fischer <bantu@owncloud.com>
Tue, 22 Oct 2013 09:22:01 +0000 (11:22 +0200)
lib/log/owncloud.php

index 53e98817902feee6043dd8996d743c0f711a5970..aecf78b2f3d5bcc09d68704111b43ad6844eed26 100644 (file)
@@ -35,7 +35,17 @@ class OC_Log_Owncloud {
        public static function init() {
                $defaultLogFile = OC_Config::getValue("datadirectory", OC::$SERVERROOT.'/data').'/owncloud.log';
                self::$logFile = OC_Config::getValue("logfile", $defaultLogFile);
-               if (!file_exists(self::$logFile)) {
+
+               /*
+               * Fall back to default log file if specified logfile does not exist
+               * and can not be created. Error suppression is required in order to
+               * not end up in the error handler which will try to log the error.
+               * A better solution (compared to error suppression) would be checking
+               * !is_writable(dirname(self::$logFile)) before touch(), but
+               * is_writable() on directories used to be pretty unreliable on Windows
+               * for at least some time.
+               */
+               if (!file_exists(self::$logFile) && !@touch(self::$logFile)) {
                        self::$logFile = $defaultLogFile;
                }
        }