/**
  * @test
  */
 public function it_gets_the_diff()
 {
     $today = Carbon::today();
     $logDate = Carbon::today()->subDays(10);
     $log = "laravel-{$logDate->toDateString()}.log";
     $this->assertSame(10, LogUtil::diffInDays($log, $today));
 }
 public function getCompressed()
 {
     $allLogs = $this->disk->files($this->remotePath);
     $logs = LogUtil::getCompressed($allLogs);
     $logs = LogUtil::mapBasename($logs);
     return $logs;
 }
 public function getCompressed()
 {
     $logs = LogUtil::getCompressed($this->logs);
     $logs = LogUtil::mapBasename($logs);
     return $logs;
 }
 /**
  * @tests
  */
 public function it_deletes_old_remote_files()
 {
     $today = Carbon::today();
     $config = config('laravel-log-keeper');
     $localRepo = new FakeLogsRepo($config);
     $remoteRepo = new FakeLogsRepo($config);
     $localRepo->setLogs([]);
     $days = $config['remoteRetentionDaysCalculated'];
     $new = "/fake/storage/logs/laravel-new-{$today->addDays($days)->toDateString()}.log.tar.bz2";
     $remoteRepo->setLogs(['/fake/storage/logs/laravel-old-2010-01-01.log', '/fake/storage/logs/laravel-old-2010-01-02.log', $new]);
     $service = new LogKeeperService($config, $localRepo, $remoteRepo, $this->getLogger());
     $service->work();
     $logs = $remoteRepo->getCompressed();
     $this->assertSame(LogUtil::mapBasename([$new]), $logs);
 }
 private function remoteCleanUp()
 {
     $this->logger->info("Starting remote clean up");
     $logs = $this->remoteRepo->getCompressed();
     foreach ($logs as $log) {
         $days = LogUtil::diffInDays($log, $this->today);
         $this->logger->info("{$log} is {$days} day(s) old");
         if ($days > $this->remoteRetentionDaysCalculated) {
             $this->logger->info("Deleting {$log}");
             $this->remoteRepo->delete($log);
         } else {
             $this->logger->info("Keeping {$log}");
         }
     }
 }