当前位置: 首页>>代码示例>>PHP>>正文


PHP Logger::popHandler方法代码示例

本文整理汇总了PHP中Monolog\Logger::popHandler方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::popHandler方法的具体用法?PHP Logger::popHandler怎么用?PHP Logger::popHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Monolog\Logger的用法示例。


在下文中一共展示了Logger::popHandler方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: work

 public function work()
 {
     $identity = $this->identify();
     $this->logger->notice(sprintf('%s waiting for work on queue(s) [%s]', $identity, join(', ', $this->queues)));
     for (;;) {
         $job = $this->metro->pop($this->queues, $this);
         if (null !== $job) {
             $jobHandler = $this->metro->createTaskLogHander($job->getId());
             $this->logger->pushHandler($jobHandler);
             $this->logger->pushProcessor(function ($record) use($job) {
                 $record['extra']['job_id'] = $job->getId();
                 return $record;
             });
             $this->workOn($job, $jobHandler);
             $this->logger->popHandler();
             $this->logger->popProcessor();
         }
         if ($this->interval <= 0) {
             return;
         }
         if (null === $job) {
             if ($this->drainMode) {
                 $this->logger->notice(sprintf('%s exiting because all queues are empty', $identity));
                 return;
             }
             usleep($this->interval * 1000.0);
         }
     }
 }
开发者ID:metro-q,项目名称:metro,代码行数:29,代码来源:Worker.php

示例2: testNotifyGetsPassedCorrectlyMappedSeverity

 /**
  * The three arguments below are provided by:
  * @dataProvider provideMappedSeverities
  *
  */
 public function testNotifyGetsPassedCorrectlyMappedSeverity($monologLevel, $expectedSeverity)
 {
     // Update the tested handler to always send messages rather than just errors.
     $this->monolog->popHandler($this->testedHandler);
     $this->testedHandler = new BugsnagHandler($this->mockBugsnag->reveal(), Logger::DEBUG);
     $this->monolog->pushHandler($this->testedHandler);
     $errorMessage = "Oh no!";
     $this->mockBugsnag->notifyError($expectedSeverity, Argument::any(), Argument::any(), $expectedSeverity)->shouldBeCalledTimes(1);
     $this->monolog->log($monologLevel, $errorMessage);
 }
开发者ID:koliesnik,项目名称:MonoSnag,代码行数:15,代码来源:BugsnagHandlerTest.php

示例3: testPushPopHandler

 /**
  * @covers Monolog\Logger::pushHandler
  * @covers Monolog\Logger::popHandler
  * @expectedException LogicException
  */
 public function testPushPopHandler()
 {
     $logger = new Logger(__METHOD__);
     $handler1 = new TestHandler();
     $handler2 = new TestHandler();
     $logger->pushHandler($handler1);
     $logger->pushHandler($handler2);
     $this->assertEquals($handler2, $logger->popHandler());
     $this->assertEquals($handler1, $logger->popHandler());
     $logger->popHandler();
 }
开发者ID:robertowest,项目名称:CuteFlow-V4,代码行数:16,代码来源:LoggerTest.php

示例4: startWorker

 /**
  * Start the worker.
  */
 public function startWorker()
 {
     $this->pheanstalk->watch($this->queue);
     $this->pheanstalk->ignore('default');
     $buildStore = Factory::getStore('Build');
     while ($this->run) {
         // Get a job from the queue:
         $job = $this->pheanstalk->reserve();
         $this->checkJobLimit();
         // Get the job data and run the job:
         $jobData = json_decode($job->getData(), true);
         if (!$this->verifyJob($job, $jobData)) {
             continue;
         }
         $this->logger->addInfo('Received build #' . $jobData['build_id'] . ' from Beanstalkd');
         // If the job comes with config data, reset our config and database connections
         // and then make sure we kill the worker afterwards:
         if (!empty($jobData['config'])) {
             $this->logger->addDebug('Using job-specific config.');
             $currentConfig = Config::getInstance()->getArray();
             $config = new Config($jobData['config']);
             Database::reset($config);
         }
         try {
             $build = BuildFactory::getBuildById($jobData['build_id']);
         } catch (\Exception $ex) {
             $this->logger->addWarning('Build #' . $jobData['build_id'] . ' does not exist in the database.');
             $this->pheanstalk->delete($job);
         }
         try {
             // Logging relevant to this build should be stored
             // against the build itself.
             $buildDbLog = new BuildDBLogHandler($build, Logger::INFO);
             $this->logger->pushHandler($buildDbLog);
             $builder = new Builder($build, $this->logger);
             $builder->execute();
             // After execution we no longer want to record the information
             // back to this specific build so the handler should be removed.
             $this->logger->popHandler($buildDbLog);
         } catch (\PDOException $ex) {
             // If we've caught a PDO Exception, it is probably not the fault of the build, but of a failed
             // connection or similar. Release the job and kill the worker.
             $this->run = false;
             $this->pheanstalk->release($job);
         } catch (\Exception $ex) {
             $build->setStatus(Build::STATUS_FAILED);
             $build->setFinished(new \DateTime());
             $build->setLog($build->getLog() . PHP_EOL . PHP_EOL . $ex->getMessage());
             $buildStore->save($build);
             $build->sendStatusPostback();
         }
         // Reset the config back to how it was prior to running this job:
         if (!empty($currentConfig)) {
             $config = new Config($currentConfig);
             Database::reset($config);
         }
         // Delete the job when we're done:
         $this->pheanstalk->delete($job);
     }
 }
开发者ID:ntoniazzi,项目名称:PHPCI,代码行数:63,代码来源:BuildWorker.php

示例5: onPost

 public function onPost()
 {
     parent::onPost();
     $commandClass = $this->getParameter('command');
     $parameters = $this->getBody();
     $parameters = !empty($parameters) ? $parameters : array();
     if (!empty($commandClass)) {
         $stream = fopen('php://memory', 'r+');
         $this->logger->pushHandler(new StreamHandler($stream, Logger::DEBUG));
         $this->executor->run(new ParameterParser\Map($commandClass, $parameters));
         $output = stream_get_contents($stream, -1, 0);
         $this->logger->popHandler();
         $this->setBody(array('output' => $output));
     } else {
         throw new \Exception('Command not available');
     }
 }
开发者ID:seytar,项目名称:psx,代码行数:17,代码来源:CommandController.php

示例6: assertDefaultHandlers

 public function assertDefaultHandlers(Logger $logger)
 {
     $handlers = array();
     do {
         try {
             $handlers[] = $handler = $logger->popHandler();
         } catch (\Exception $e) {
         }
     } while (!isset($e));
     $this->assertSame(array(), $handlers, 'There are more handlers defined than should be');
 }
开发者ID:graze,项目名称:monolog-extensions,代码行数:11,代码来源:LoggerBuilderIntegrationTest.php

示例7: execute

 /**
  * Pulls all pending builds from the database and runs them.
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->output = $output;
     // For verbose mode we want to output all informational and above
     // messages to the symphony output interface.
     if ($input->hasOption('verbose') && $input->getOption('verbose')) {
         $this->logger->pushHandler(new OutputLogHandler($this->output, Logger::INFO));
     }
     $running = $this->validateRunningBuilds();
     $this->logger->pushProcessor(new LoggedBuildContextTidier());
     $this->logger->addInfo(Lang::get('finding_builds'));
     $store = Factory::getStore('Build');
     $result = $store->getByStatus(0, $this->maxBuilds);
     $this->logger->addInfo(Lang::get('found_n_builds', count($result['items'])));
     $builds = 0;
     while (count($result['items'])) {
         $build = array_shift($result['items']);
         $build = BuildFactory::getBuild($build);
         // Skip build (for now) if there's already a build running in that project:
         if (!$this->isFromDaemon && in_array($build->getProjectId(), $running)) {
             $this->logger->addInfo(Lang::get('skipping_build', $build->getId()));
             $result['items'][] = $build;
             // Re-run build validator:
             $running = $this->validateRunningBuilds();
             continue;
         }
         $builds++;
         try {
             // Logging relevant to this build should be stored
             // against the build itself.
             $buildDbLog = new BuildDBLogHandler($build, Logger::INFO);
             $this->logger->pushHandler($buildDbLog);
             $builder = new Builder($build, $this->logger);
             $builder->execute();
             // After execution we no longer want to record the information
             // back to this specific build so the handler should be removed.
             $this->logger->popHandler($buildDbLog);
         } catch (\Exception $ex) {
             $build->setStatus(Build::STATUS_FAILED);
             $build->setFinished(new \DateTime());
             $build->setLog($build->getLog() . PHP_EOL . PHP_EOL . $ex->getMessage());
             $store->save($build);
         }
     }
     $this->logger->addInfo(Lang::get('finished_processing_builds'));
     return $builds;
 }
开发者ID:stefanius,项目名称:phpci-box,代码行数:50,代码来源:RunCommand.php

示例8: testPreAndPostCommandHandlersAreRun

 public function testPreAndPostCommandHandlersAreRun()
 {
     $preLogger = new Logger('sdfs', array(new TestHandler()));
     $this->dispatcher->addPreCommandHandler(function ($command) use($preLogger) {
         $preLogger->info('pre');
     });
     $postLogger = new Logger('fghhgf', array(new TestHandler()));
     $this->dispatcher->addPostCommandHandler(function ($command) use($postLogger) {
         $postLogger->info('post');
     });
     $command = $this->createCommand();
     $this->dispatcher->handleCommands(array($command));
     $records = $preLogger->popHandler()->getRecords();
     $this->assertEquals('pre', $records[0]['message']);
     $records = $postLogger->popHandler()->getRecords();
     $this->assertEquals('post', $records[0]['message']);
 }
开发者ID:stiggg,项目名称:command-dispatcher,代码行数:17,代码来源:DispatcherTest.php

示例9: execute

 /**
  * Pulls all pending builds from the database and runs them.
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->output = $output;
     // For verbose mode we want to output all informational and above
     // messages to the symphony output interface.
     if ($input->hasOption('verbose')) {
         $this->logger->pushHandler(new OutputLogHandler($this->output, Logger::INFO));
     }
     $this->logger->pushProcessor(new LoggedBuildContextTidier());
     $this->logger->addInfo("Finding builds to process");
     $store = Factory::getStore('Build');
     $result = $store->getByStatus(0, $this->maxBuilds);
     $this->logger->addInfo(sprintf("Found %d builds", count($result['items'])));
     $builds = 0;
     foreach ($result['items'] as $build) {
         $builds++;
         $build = BuildFactory::getBuild($build);
         try {
             // Logging relevant to this build should be stored
             // against the build itself.
             $buildDbLog = new BuildDBLogHandler($build, Logger::INFO);
             $this->logger->pushHandler($buildDbLog);
             $builder = new Builder($build, $this->logger);
             $builder->execute();
             // After execution we no longer want to record the information
             // back to this specific build so the handler should be removed.
             $this->logger->popHandler($buildDbLog);
         } catch (\Exception $ex) {
             $build->setStatus(Build::STATUS_FAILED);
             $build->setLog($build->getLog() . PHP_EOL . PHP_EOL . $ex->getMessage());
             $store->save($build);
         }
     }
     $this->logger->addInfo("Finished processing builds");
     return $builds;
 }
开发者ID:kukupigs,项目名称:PHPCI,代码行数:39,代码来源:RunCommand.php

示例10: popHandler

 /**
  * Pops a handler from the stack
  *
  * @return \Monolog\HandlerInterface 
  * @static 
  */
 public static function popHandler()
 {
     return \Monolog\Logger::popHandler();
 }
开发者ID:samcrosoft,项目名称:MicroTranslate,代码行数:10,代码来源:lumen_ide_helper.php

示例11: popHandler

 /**
  * Pops a handler from the stack
  *
  * @return \Monolog\Handler\HandlerInterface
  */
 public function popHandler()
 {
     return $this->monolog->popHandler();
 }
开发者ID:projek-xyz,项目名称:slim-monolog,代码行数:9,代码来源:Monolog.php

示例12: popHandler

 /**
  * @return HandlerInterface
  */
 public function popHandler()
 {
     return parent::popHandler();
 }
开发者ID:akentner,项目名称:incoming-ftp,代码行数:7,代码来源:LoggerProxy.php

示例13: popHandler

 /**
  * Pops a handler from the stack
  *
  * @return HandlerInterface
  */
 public function popHandler()
 {
     $handler = parent::popHandler();
     array_shift($this->filters);
     return $handler;
 }
开发者ID:sugiphp,项目名称:logger,代码行数:11,代码来源:Logger.php


注:本文中的Monolog\Logger::popHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。