summaryrefslogtreecommitdiffstats
path: root/lib/log/owncloud.php
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@owncloud.com>2013-10-20 23:58:07 +0200
committerAndreas Fischer <bantu@owncloud.com>2013-10-22 11:22:01 +0200
commitf82885b124f4a131644948d409a63b35da3e0962 (patch)
tree6875a9d0f67e6ae063b98ad225667e4897e0928a /lib/log/owncloud.php
parent7923f93ee3b63cf1359f03b9d5beecb486b7e8a5 (diff)
downloadnextcloud-server-f82885b124f4a131644948d409a63b35da3e0962.tar.gz
nextcloud-server-f82885b124f4a131644948d409a63b35da3e0962.zip
Try to create custom log file before falling back to default.
Diffstat (limited to 'lib/log/owncloud.php')
-rw-r--r--lib/log/owncloud.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/log/owncloud.php b/lib/log/owncloud.php
index 53e98817902..aecf78b2f3d 100644
--- a/lib/log/owncloud.php
+++ b/lib/log/owncloud.php
@@ -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;
}
}