2020-01-14 10:43:50 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2024-05-30 20:13:41 +02:00
|
|
|
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2020-01-14 10:43:50 +01:00
|
|
|
*/
|
|
|
|
namespace OCA\WorkflowEngine\BackgroundJobs;
|
|
|
|
|
|
|
|
use OCA\WorkflowEngine\AppInfo\Application;
|
2022-12-05 10:13:34 +01:00
|
|
|
use OCP\AppFramework\Utility\ITimeFactory;
|
|
|
|
use OCP\BackgroundJob\TimedJob;
|
2025-02-03 15:34:01 +01:00
|
|
|
use OCP\IConfig;
|
2020-01-14 10:43:50 +01:00
|
|
|
use OCP\Log\RotationTrait;
|
2025-02-03 15:34:01 +01:00
|
|
|
use OCP\Server;
|
2020-01-14 10:43:50 +01:00
|
|
|
|
|
|
|
class Rotate extends TimedJob {
|
|
|
|
use RotationTrait;
|
|
|
|
|
2022-12-05 10:13:34 +01:00
|
|
|
public function __construct(ITimeFactory $time) {
|
|
|
|
parent::__construct($time);
|
2020-10-05 15:12:57 +02:00
|
|
|
$this->setInterval(60 * 60 * 3);
|
2020-01-14 10:43:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function run($argument) {
|
2025-02-03 15:34:01 +01:00
|
|
|
$config = Server::get(IConfig::class);
|
2020-01-14 10:43:50 +01:00
|
|
|
$default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/flow.log';
|
|
|
|
$this->filePath = trim((string)$config->getAppValue(Application::APP_ID, 'logfile', $default));
|
|
|
|
|
|
|
|
if ($this->filePath === '') {
|
|
|
|
// disabled, nothing to do
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->maxSize = $config->getSystemValue('log_rotate_size', 100 * 1024 * 1024);
|
|
|
|
|
|
|
|
if ($this->shouldRotateBySize()) {
|
|
|
|
$this->rotate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|