summaryrefslogtreecommitdiffstats
path: root/lib/private/log/owncloud.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/log/owncloud.php')
-rw-r--r--lib/private/log/owncloud.php13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/private/log/owncloud.php b/lib/private/log/owncloud.php
index a408e3830d6..15cace88f41 100644
--- a/lib/private/log/owncloud.php
+++ b/lib/private/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;
}
}
@@ -61,6 +71,7 @@ class OC_Log_Owncloud {
$entry=array('app'=>$app, 'message'=>$message, 'level'=>$level, 'time'=> $time->format($format));
$entry = json_encode($entry);
$handle = @fopen(self::$logFile, 'a');
+ @chmod(self::$logFile, 0640);
if ($handle) {
fwrite($handle, $entry."\n");
fclose($handle);