Get the logfile location while running the logrotate cron job instead of when registering the job

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2017-01-02 16:16:15 +01:00 committed by Morris Jobke
parent 4a2fbe9a5b
commit 54f96e5f58
No known key found for this signature in database
GPG Key ID: 9CE5ED29E7FCD38A
2 changed files with 4 additions and 2 deletions

View File

@ -881,7 +881,7 @@ class OC {
if ($systemConfig->getValue('installed', false) && $systemConfig->getValue('log_rotate_size', false) && !self::checkUpgrade(false)) { if ($systemConfig->getValue('installed', false) && $systemConfig->getValue('log_rotate_size', false) && !self::checkUpgrade(false)) {
//don't try to do this before we are properly setup //don't try to do this before we are properly setup
//use custom logfile path if defined, otherwise use default of nextcloud.log in data directory //use custom logfile path if defined, otherwise use default of nextcloud.log in data directory
\OCP\BackgroundJob::registerJob('OC\Log\Rotate', $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', OC::$SERVERROOT . '/data') . '/nextcloud.log')); \OC::$server->getJobList()->add('OC\Log\Rotate');
} }
} }

View File

@ -32,7 +32,9 @@ namespace OC\Log;
*/ */
class Rotate extends \OC\BackgroundJob\Job { class Rotate extends \OC\BackgroundJob\Job {
private $max_log_size; private $max_log_size;
public function run($logFile) { public function run($dummy) {
$systemConfig = \OC::$server->getSystemConfig();
$logFile = $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/nextcloud.log');
$this->max_log_size = \OC::$server->getConfig()->getSystemValue('log_rotate_size', false); $this->max_log_size = \OC::$server->getConfig()->getSystemValue('log_rotate_size', false);
if ($this->max_log_size) { if ($this->max_log_size) {
$filesize = @filesize($logFile); $filesize = @filesize($logFile);