コード例 #1
0
ファイル: LevelRange.php プロジェクト: jacklaaa89/PHPlog
 /**
  * @see \PHPLog\FilterAbstract::decide()
  */
 public function decide(Event $event)
 {
     //if level max is not a Level.
     if (!$this->levelMax instanceof Level) {
         return FilterAbstract::NEUTRAL;
     }
     //if level min is not a level.
     if (!$this->levelMin instanceof Level) {
         return FilterAbstract::NEUTRAL;
     }
     //if level min is equal to all or is greater than max.
     if ($this->levelMin->equals(Level::all()) || $this->levelMin->isGreaterOrEqualTo($this->levelMax)) {
         return FilterAbstract::NEUTRAL;
     }
     //if max if equal to off.
     if ($this->levelMax->equals(Level::off())) {
         return FilterAbstract::NEUTRAL;
     }
     //check that the event level is between the range.
     $lmi = $this->levelMin->getIntLevel();
     $lma = $this->levelMax->getIntLevel();
     $e = $event->getLevel()->getIntLevel();
     if ($e >= $lmi && $e <= $lma) {
         //in the range.
         return $this->acceptOnMatch ? FilterAbstract::ACCEPT : FilterAbstract::DENY;
     }
     return FilterAbstract::NEUTRAL;
 }
コード例 #2
0
ファイル: LevelMatch.php プロジェクト: jacklaaa89/PHPlog
 /**
  * @see \PHPLog\FilterAbstract::decide()
  */
 public function decide(Event $event)
 {
     if (!$this->levelToMatch instanceof Level) {
         return FilterAbstract::NEUTRAL;
     }
     if ($this->levelToMatch->equals($event->getLevel())) {
         return $this->acceptOnMatch ? FilterAbstract::ACCEPT : FilterAbstract::DENY;
     }
     return FilterAbstract::NEUTRAL;
 }
コード例 #3
0
ファイル: ClassMatch.php プロジェクト: jacklaaa89/PHPlog
 /**
  * @see \PHPLog\FilterAbstract::decide()
  */
 public function decide(Event $event)
 {
     if ($this->className === null) {
         return FilterAbstract::NEUTRAL;
     }
     if ($event->getClass() === null) {
         return FilterAbstract::NEUTRAL;
     }
     if ($event->getClass() == $this->className) {
         return $this->acceptOnMatch ? FilterAbstract::ACCEPT : FilterAbstract::DENY;
     }
     return FilterAbstract::NEUTRAL;
 }
コード例 #4
0
ファイル: Console.php プロジェクト: jacklaaa89/PHPlog
 /**
  * attempts to set the current stream target for this log entry.
  * @param Event $event the evetn we are attempting to log.
  */
 private function setTarget(Event $event)
 {
     if ($this->useMinErrorLevel) {
         $level = $event->getLevel();
         $this->target = $level->isGreaterOrEqualTo($this->minErrorLevel) ? self::STDERR : self::STDOUT;
     }
     if (is_resource($this->handle)) {
         fclose($this->handle);
     }
     $this->handle = fopen($this->target, 'w');
     if (!is_resource($this->handle)) {
         $this->close();
     }
 }
コード例 #5
0
ファイル: TimeSpanFile.php プロジェクト: jacklaaa89/PHPlog
 /**
  * generates the date that will be used in the file name.
  * mainly used to determine if the file has changed.
  * @param Event $event the event that will be logged.
  * @return string the date converted into the correct format.
  */
 public function getDate(Event $event)
 {
     return date($this->timespan, $event->getDate());
 }