1
0

Rotate.php 999 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\WorkflowEngine\BackgroundJobs;
  7. use OCA\WorkflowEngine\AppInfo\Application;
  8. use OCP\AppFramework\Utility\ITimeFactory;
  9. use OCP\BackgroundJob\TimedJob;
  10. use OCP\Log\RotationTrait;
  11. class Rotate extends TimedJob {
  12. use RotationTrait;
  13. public function __construct(ITimeFactory $time) {
  14. parent::__construct($time);
  15. $this->setInterval(60 * 60 * 3);
  16. }
  17. protected function run($argument) {
  18. $config = \OC::$server->getConfig();
  19. $default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/flow.log';
  20. $this->filePath = trim((string)$config->getAppValue(Application::APP_ID, 'logfile', $default));
  21. if ($this->filePath === '') {
  22. // disabled, nothing to do
  23. return;
  24. }
  25. $this->maxSize = $config->getSystemValue('log_rotate_size', 100 * 1024 * 1024);
  26. if ($this->shouldRotateBySize()) {
  27. $this->rotate();
  28. }
  29. }
  30. }