setLogger() public method

Inject the logging object into the worker
public setLogger ( Psr\Log\LoggerInterface $logger )
$logger Psr\Log\LoggerInterface
コード例 #1
0
 public function setUp()
 {
     parent::setUp();
     // Register a worker to test with
     $this->worker = new Resque_Worker('jobs');
     $this->worker->setLogger(new Resque_Log());
 }
コード例 #2
0
ファイル: PHPResque.php プロジェクト: Ecter/php-resque-bundle
 private function work()
 {
     $worker = new \Resque_Worker(explode(',', $this->queue));
     if ($this->logger instanceof LoggerInterface) {
         $worker->setLogger($this->logger);
     }
     if (method_exists($worker, 'setStayAlive')) {
         $worker->setStayAlive($this->stayAlive);
     }
     fwrite(STDOUT, '*** Starting worker ' . $worker . "\n");
     $worker->work($this->checker_interval, $this->blocking);
 }
コード例 #3
0
ファイル: Resque.php プロジェクト: mpclarkson/resque-bundle
 /**
  * @todo - Clean this up, for now, prune dead workers, just in case
  */
 public function pruneDeadWorkers()
 {
     $worker = new \Resque_Worker('temp');
     $worker->setLogger(new NullLogger());
     $worker->pruneDeadWorkers();
 }
コード例 #4
0
ファイル: WorkerTest.php プロジェクト: Balamir/php-resque
 public function testBlockingListPop()
 {
     $worker = new Resque_Worker('jobs');
     $worker->setLogger(new Resque_Log());
     $worker->registerWorker();
     Resque::enqueue('jobs', 'Test_Job_1');
     Resque::enqueue('jobs', 'Test_Job_2');
     $i = 1;
     while ($job = $worker->reserve(true, 1)) {
         $this->assertEquals('Test_Job_' . $i, $job->payload['class']);
         if ($i == 2) {
             break;
         }
         $i++;
     }
     $this->assertEquals(2, $i);
 }
コード例 #5
0
 public function pruneDeadWorkers()
 {
     // HACK, prune dead workers, just in case
     $worker = new \Resque_Worker('temp');
     $worker->setLogger(new NullLogger());
     $worker->pruneDeadWorkers();
 }
コード例 #6
0
 /**
  * Start a single worker
  *
  * @param bool $isForked - is this worker forked
  */
 protected function startWorker($isForked = false)
 {
     $queues = explode(',', $this->queue);
     $worker = new Resque_Worker($queues);
     $worker->setLogger($this->logger);
     if (!$isForked) {
         $PIDFILE = getenv('PIDFILE');
         if ($PIDFILE) {
             file_put_contents($PIDFILE, getmypid()) or die('Could not write PID information to ' . $PIDFILE);
         }
     }
     fwrite(STDOUT, '[+] Starting worker ' . $worker . " " . $this->interval . PHP_EOL);
     $worker->work($this->interval);
 }