示例#1
0
文件: Logger.php 项目: rsms/phpab
 /**
  * Forward a message to the current <samp>{@link LogHandler}</samp>
  *
  * If <samp>$msg</samp> is an <samp>object</samp>, it will be converted to a string 
  * using $obj->__toString()</samp>. If <samp>$msg</samp> is an <samp>Exception</samp>,
  * it will be converted to a string using <samp>ABException::format($e)</samp>. However,
  * this is done by the LogHandler, so these are more or less guidelines than rules.
  *
  * @param  LogRecord
  * @return void
  */
 public function log(LogRecord $rec)
 {
     if ($this->handler != null) {
         // don't log?
         if ($rec->getLevel() < $this->level) {
             return;
         }
         // Filter
         foreach ($this->filters as $filter) {
             try {
                 if (!$filter->filter($rec)) {
                     return;
                 }
             } catch (Exception $e) {
                 $rec->setMessage($rec->getMessage() . ' [LogFilterException in ' . get_class($filter) . '->filter(): ' . $e->getMessage() . '] ');
             }
         }
         // Publish
         $this->handler->publish($rec);
     }
 }