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

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