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

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