You are here

public function UltimateCronDatabaseLogger::cleanup in Ultimate Cron 7.2

Cleanup logs.

File

plugins/ultimate_cron/logger/database.class.php, line 44
Database logger for Ultimate Cron.

Class

UltimateCronDatabaseLogger
Class for using database as log storage.

Code

public function cleanup() {
  $jobs = _ultimate_cron_job_load_all();
  $current = 1;
  $max = 0;
  $count_deleted = array();
  foreach ($jobs as $job) {
    if ($job
      ->getPlugin($this->type)->name === $this->name) {
      $max++;
    }
  }
  foreach ($jobs as $job) {
    if ($job
      ->getPlugin($this->type)->name === $this->name) {
      $deleted_logs = $this
        ->cleanupJob($job);
      $class = _ultimate_cron_get_class('job');
      if ($class::$currentJob) {
        $class::$currentJob
          ->setProgress($current / $max);
        $current++;
      }
      if ($deleted_logs > 0) {

        // Store number of deleted messages for each job.
        $count_deleted[$job->name] = $deleted_logs;
      }
    }
  }
  if (!empty($count_deleted)) {
    watchdog('database_logger', '@count_entries log entries removed for @jobs_count jobs', array(
      '@count_entries' => array_sum($count_deleted),
      '@jobs_count' => count($count_deleted),
    ), WATCHDOG_INFO);
  }
}