summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2016-03-21 15:21:22 +0100
committerLukas Reschke <lukas@owncloud.com>2016-03-21 15:48:01 +0100
commit7adae4476f2a4488a00ce822cd2edc726b475c0e (patch)
treea204c901f174190757fe0439c4aaa306a3a43596 /lib
parent86581f66265be0dddb97f67ac867a5cb92d335e0 (diff)
downloadnextcloud-server-7adae4476f2a4488a00ce822cd2edc726b475c0e.tar.gz
nextcloud-server-7adae4476f2a4488a00ce822cd2edc726b475c0e.zip
Log more information by default
This modifies the logger to add the following logging information by default: - Request Method - Request URL - Current user
Diffstat (limited to 'lib')
-rw-r--r--lib/private/log/owncloud.php23
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/private/log/owncloud.php b/lib/private/log/owncloud.php
index 6399d7ee588..ec4af29dc84 100644
--- a/lib/private/log/owncloud.php
+++ b/lib/private/log/owncloud.php
@@ -88,14 +88,21 @@ class OC_Log_Owncloud {
$remoteAddr = $request->getRemoteAddress();
// remove username/passwords from URLs before writing the to the log file
$time = $time->format($format);
- $minLevel=min($config->getValue( "loglevel", \OCP\Util::WARN ), \OCP\Util::ERROR);
- if($minLevel == \OCP\Util::DEBUG) {
- $url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '--';
- $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : '--';
- $entry = compact('reqId', 'remoteAddr', 'app', 'message', 'level', 'time', 'method', 'url');
- } else {
- $entry = compact('reqId', 'remoteAddr', 'app', 'message', 'level', 'time');
- }
+ $url = ($request->getRequestUri() !== '') ? $request->getRequestUri() : '--';
+ $method = is_string($request->getMethod()) ? $request->getMethod() : '--';
+ $userObj = \OC::$server->getUserSession()->getUser();
+ $user = !is_null($userObj) ? $userObj->getUID() : '--';
+ $entry = compact(
+ 'reqId',
+ 'remoteAddr',
+ 'app',
+ 'message',
+ 'level',
+ 'time',
+ 'method',
+ 'url',
+ 'user'
+ );
$entry = json_encode($entry);
$handle = @fopen(self::$logFile, 'a');
@chmod(self::$logFile, 0640);