diff --git a/composer.json b/composer.json index 6e30fad..45f2b6d 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ ], "require": { "php": ">=5.3.0", - "monolog/monolog": "~1.3", + "monolog/monolog": "~1.3||~2", "clio/clio": "0.1.*" }, "require-dev": { diff --git a/demo/queues/BeanstalkSampleQueue.php b/demo/queues/BeanstalkSampleQueue.php index 9335e4f..8824943 100644 --- a/demo/queues/BeanstalkSampleQueue.php +++ b/demo/queues/BeanstalkSampleQueue.php @@ -38,7 +38,7 @@ public function getJob($jobId = null) public function updateJob($jobId = null, $resultData = null) { - $this->resultLog->addInfo('Result: ID='.$jobId, $resultData); + $this->resultLog->info('Result: ID='.$jobId, $resultData); } public function clearJob($jobId = null) diff --git a/src/PHPQueue/Runner.php b/src/PHPQueue/Runner.php index ff54957..284a55e 100644 --- a/src/PHPQueue/Runner.php +++ b/src/PHPQueue/Runner.php @@ -83,7 +83,7 @@ protected function checkAndCycleLog() $this->current_log_check++; if ($this->current_log_check > $this->max_check_interval) { if ($this->current_date != date('Ymd')) { - $this->logger->addAlert("Cycling log file now."); + $this->logger->alert("Cycling log file now."); $this->logger = Logger::cycleLog( $this->queue_name , $this->log_level @@ -101,11 +101,11 @@ public function workJob() try { $newJob = Base::getJob($this->queue); } catch (\Exception $ex) { - $this->logger->addError($ex->getMessage()); + $this->logger->error($ex->getMessage()); $sleepTime = self::RUN_USLEEP * 5; } if (empty($newJob)) { - $this->logger->addNotice("No Job found."); + $this->logger->notice("No Job found."); $sleepTime = self::RUN_USLEEP * 10; } else { try { @@ -115,7 +115,7 @@ public function workJob() if (is_string($newJob->worker)) { $result_data = $this->processWorker($newJob->worker, $newJob); } elseif (is_array($newJob->worker)) { - $this->logger->addInfo(sprintf("Running chained new job (%s) with workers", $newJob->job_id), $newJob->worker); + $this->logger->info(sprintf("Running chained new job (%s) with workers", $newJob->job_id), $newJob->worker); foreach ($newJob->worker as $worker_name) { $result_data = $this->processWorker($worker_name, $newJob); $newJob->data = $result_data; @@ -124,22 +124,22 @@ public function workJob() return Base::updateJob($this->queue, $newJob->job_id, $result_data); } catch (\Exception $ex) { - $this->logger->addError($ex->getMessage()); - $this->logger->addInfo(sprintf('Releasing job (%s).', $newJob->job_id)); + $this->logger->error($ex->getMessage()); + $this->logger->info(sprintf('Releasing job (%s).', $newJob->job_id)); $this->queue->releaseJob($newJob->job_id); $sleepTime = self::RUN_USLEEP * 5; } } - $this->logger->addInfo('Sleeping ' . ceil($sleepTime / 1000000) . ' seconds.'); + $this->logger->info('Sleeping ' . ceil($sleepTime / 1000000) . ' seconds.'); usleep($sleepTime); } protected function processWorker($worker_name, $new_job) { - $this->logger->addInfo(sprintf("Running new job (%s) with worker: %s", $new_job->job_id, $worker_name)); + $this->logger->info(sprintf("Running new job (%s) with worker: %s", $new_job->job_id, $worker_name)); $worker = Base::getWorker($worker_name); Base::workJob($worker, $new_job); - $this->logger->addInfo(sprintf('Worker is done. Updating job (%s). Result:', $new_job->job_id), $worker->result_data); + $this->logger->info(sprintf('Worker is done. Updating job (%s). Result:', $new_job->job_id), $worker->result_data); return $worker->result_data; }