summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2023-04-21 18:17:28 +0200
committerRobin Appelman <robin@icewind.nl>2023-04-24 17:13:20 +0200
commit05dc96f60df22d2fe20d0bab2e37b382b0c4216d (patch)
tree53f57e09b87ceb458726de16874359032ce65860 /lib/private
parent1bff4e23bfcfec1ed034f9ea6a1f069cbe2f906d (diff)
downloadnextcloud-server-05dc96f60df22d2fe20d0bab2e37b382b0c4216d.tar.gz
nextcloud-server-05dc96f60df22d2fe20d0bab2e37b382b0c4216d.zip
debug log requests made by dav external storage/shares
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Files/Storage/DAV.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php
index 9388e2b20a8..b332f3b7c4a 100644
--- a/lib/private/Files/Storage/DAV.php
+++ b/lib/private/Files/Storage/DAV.php
@@ -44,6 +44,7 @@ use OC\Files\Filesystem;
use OC\MemCache\ArrayCache;
use OCP\AppFramework\Http;
use OCP\Constants;
+use OCP\Diagnostics\IEventLogger;
use OCP\Files\FileInfo;
use OCP\Files\ForbiddenException;
use OCP\Files\StorageInvalidException;
@@ -56,6 +57,7 @@ use Sabre\DAV\Xml\Property\ResourceType;
use Sabre\HTTP\ClientException;
use Sabre\HTTP\ClientHttpException;
use Psr\Log\LoggerInterface;
+use Sabre\HTTP\RequestInterface;
/**
* Class DAV
@@ -87,6 +89,8 @@ class DAV extends Common {
protected $httpClientService;
/** @var ICertificateManager */
protected $certManager;
+ protected LoggerInterface $logger;
+ protected IEventLogger $eventLogger;
/**
* @param array $params
@@ -128,6 +132,8 @@ class DAV extends Common {
} else {
throw new \Exception('Invalid webdav storage configuration');
}
+ $this->logger = \OC::$server->get(LoggerInterface::class);
+ $this->eventLogger = \OC::$server->get(IEventLogger::class);
}
protected function init() {
@@ -162,6 +168,18 @@ class DAV extends Common {
$this->client->addCurlSetting(CURLOPT_CAINFO, $this->certPath);
}
}
+
+ $lastRequestStart = 0;
+ $this->client->on('beforeRequest', function (RequestInterface $request) use (&$lastRequestStart) {
+ $this->logger->debug("sending dav " . $request->getMethod() . " request to external storage: " . $request->getAbsoluteUrl(), ['app' => 'dav']);
+ $lastRequestStart = microtime(true);
+ $this->eventLogger->start('fs:storage:dav:request', "Sending dav request to external storage");
+ });
+ $this->client->on('afterRequest', function (RequestInterface $request) use (&$lastRequestStart) {
+ $elapsed = microtime(true) - $lastRequestStart;
+ $this->logger->debug("dav " . $request->getMethod() . " request to external storage: " . $request->getAbsoluteUrl() . " took " . round($elapsed * 1000, 1) . "ms", ['app' => 'dav']);
+ $this->eventLogger->end('fs:storage:dav:request');
+ });
}
/**