Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2016-03-21 17:21:22 +0300
committerLukas Reschke <lukas@owncloud.com>2016-03-22 11:46:02 +0300
commit177ad3985422ca80b3a19bcfd15e11ec78a99e3a (patch)
tree353ec0768ca77793fe0762d4c98e0cd0e0d4b4f6 /lib
parentda95db78d06d87ee0f611bdfab9ea8f34d0370dc (diff)
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);