err() 공개 정적인 메소드

public static err ( $msg, $context = [] )
예제 #1
0
 public function testUseSimpleLogger()
 {
     Logger::useSimpleLogger($this->_logFile);
     Logger::info('xxinfoxx');
     Logger::err('xxerrxx');
     Logger::debug('xxdebugxx');
     $contents = file_get_contents($this->_logFile);
     $ms = null;
     $this->assertEquals(1, preg_match('/xxinfoxx/', $contents, $ms));
     $this->assertEquals(1, preg_match('/xxerrxx/', $contents, $ms));
     $this->assertEquals(1, preg_match('/xxdebugxx/', $contents, $ms));
     Logger::useNullLogger();
     Logger::info('bbbb');
     $contents1 = file_get_contents($this->_logFile);
     $this->assertEquals($contents1, $contents);
 }
예제 #2
0
 /**
  * to fork to create a process and run $target in there
  *
  * @param
  *            Runnable | \callable $target
  * @return ChildProcess
  * @throws \InvalidArgumentException
  */
 public static function fork($target)
 {
     if (!\is_callable($target) && !$target instanceof Runnable) {
         throw new \InvalidArgumentException('$target must be a valid callback or Comos\\Qpm\\Process\\Runnable');
     }
     $pid = \pcntl_fork();
     if ($pid == -1) {
         throw new FailToForkException('fail to folk.');
     }
     if ($pid == 0) {
         try {
             if ($target instanceof Runnable) {
                 $code = $target->run();
             } else {
                 $code = \call_user_func($target);
             }
         } catch (\Exception $ex) {
             Logger::err($ex);
             $code = -1;
         }
         if (\is_null($code)) {
             $code = 0;
         } elseif (!\is_int($code)) {
             $code = 1;
         }
         exit($code);
     }
     return new ChildProcess($pid, self::getCurrentPid());
 }
예제 #3
0
파일: ProcessStub.php 프로젝트: comos/qpm
 /**
  * 
  * @return boolean
  */
 private function invokeOnTimeout()
 {
     $onTimeout = $this->getConfig()->getOnTimeout();
     if (!$onTimeout) {
         return false;
     }
     try {
         \call_user_func($onTimeout, $this->getProcess());
     } catch (\Exception $e) {
         \Comos\Qpm\Log\Logger::err($e);
         return false;
     }
     return true;
 }
예제 #4
0
 public function stop()
 {
     Logger::debug(__CLASS__ . '::' . __METHOD__ . '()');
     if (!$this->_currentProcess->isCurrent()) {
         return;
     }
     $this->_stoped = true;
     foreach ($this->_children as $child) {
         try {
             $child->getProcess()->kill();
         } catch (Exception $ex) {
             Logger::err($ex);
         }
     }
     $this->_waitToEnd();
 }
예제 #5
0
 public function stop()
 {
     if (!$this->_currentProcess->isCurrent()) {
         return;
     }
     $this->_stoped = true;
     foreach ($this->_children as $stub) {
         try {
             $stub->getProcess()->kill();
         } catch (\Exception $ex) {
             Logger::err('fail to kill process', array('exception' => $ex));
         }
     }
     while (count($this->_children)) {
         $status = 0;
         $pid = \pcntl_wait($status);
         unset($this->_children[$pid]);
     }
 }