You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LogSettingsController.php 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Georg Ehrke <oc.list@georgehrke.com>
  8. * @author Lukas Reschke <lukas@statuscode.ch>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. * @author Thomas Müller <thomas.mueller@tmit.eu>
  11. *
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. namespace OCA\Settings\Controller;
  28. use OC\Log;
  29. use OCP\AppFramework\Controller;
  30. use OCP\AppFramework\Http\StreamResponse;
  31. use OCP\IRequest;
  32. class LogSettingsController extends Controller {
  33. /** @var Log */
  34. private $log;
  35. public function __construct(string $appName, IRequest $request, Log $logger) {
  36. parent::__construct($appName, $request);
  37. $this->log = $logger;
  38. }
  39. /**
  40. * download logfile
  41. *
  42. * @NoCSRFRequired
  43. *
  44. * @return StreamResponse
  45. */
  46. public function download() {
  47. if (!$this->log instanceof Log) {
  48. throw new \UnexpectedValueException('Log file not available');
  49. }
  50. $resp = new StreamResponse($this->log->getLogPath());
  51. $resp->addHeader('Content-Type', 'application/octet-stream');
  52. $resp->addHeader('Content-Disposition', 'attachment; filename="nextcloud.log"');
  53. return $resp;
  54. }
  55. }