private function localWork()
{
$logs = $this->localRepo->getLogs();
foreach ($logs as $log) {
$this->logger->info("Analysing {$log}");
$days = LogUtil::diffInDays($log, $this->today);
$this->logger->info("{$log} is {$days} day(s) old");
if ($days > $this->localRetentionDays && $days <= $this->remoteRetentionDaysCalculated) {
$compressedName = "{$log}.tar.bz2";
if ($this->config['enabled_remote']) {
$this->logger->info("Compressing {$log} into {$compressedName}");
$this->localRepo->compress($log, $compressedName);
$content = $this->localRepo->get($compressedName);
$this->logger->info("Uploading {$compressedName}");
$this->remoteRepo->put($compressedName, $content);
$this->logger->info("Deleting {$compressedName} locally");
$this->localRepo->delete($compressedName);
} else {
$this->logger->info("Deleting {$log} locally");
$this->localRepo->delete($log);
$this->logger->info("Not uploading {$compressedName} because enabled_remote is false");
}
} elseif ($days > $this->localRetentionDays && $days > $this->remoteRetentionDaysCalculated) {
$this->logger->info("Deleting {$log} because it is to old to be kept either local or remotely");
// file too old to be stored either remotely or locally
$this->localRepo->delete($log);
} else {
$this->logger->info("Keeping {$log}");
}
}
}