public function append(Ideasa_Log4php_LoggerLoggingEvent $event)
 {
     if ($this->layout !== null) {
         $level = $event->getLevel();
         if ($level->isGreaterOrEqual(Ideasa_Log4php_LoggerLevel::getLevelError())) {
             trigger_error($this->layout->format($event), E_USER_ERROR);
         } else {
             if ($level->isGreaterOrEqual(Ideasa_Log4php_LoggerLevel::getLevelWarn())) {
                 trigger_error($this->layout->format($event), E_USER_WARNING);
             } else {
                 trigger_error($this->layout->format($event), E_USER_NOTICE);
             }
         }
     }
 }
Example #2
0
 /**
  * Log a message with the WARN level.
  *
  * @param mixed $message message
  * @param mixed $caller caller object or caller string id
  */
 public function warn($message, $caller = null)
 {
     $this->log(Ideasa_Log4php_LoggerLevel::getLevelWarn(), $message, $caller);
 }
 public function append(Ideasa_Log4php_LoggerLoggingEvent $event)
 {
     if ($this->_option == NULL) {
         $this->_option = LOG_PID | LOG_CONS;
     }
     $level = $event->getLevel();
     if ($this->layout === null) {
         $message = $event->getRenderedMessage();
     } else {
         $message = $this->layout->format($event);
     }
     // If the priority of a syslog message can be overridden by a value defined in the properties-file,
     // use that value, else use the one that is defined in the code.
     if (!$this->dry) {
         // Attach the process ID to the message, use the facility defined in the .properties-file
         openlog($this->_ident, $this->_option, $this->_facility);
         if ($this->_overridePriority) {
             syslog($this->_priority, $message);
         } else {
             if ($level->isGreaterOrEqual(Ideasa_Log4php_LoggerLevel::getLevelFatal())) {
                 syslog(LOG_ALERT, $message);
             } else {
                 if ($level->isGreaterOrEqual(Ideasa_Log4php_LoggerLevel::getLevelError())) {
                     syslog(LOG_ERR, $message);
                 } else {
                     if ($level->isGreaterOrEqual(Ideasa_Log4php_LoggerLevel::getLevelWarn())) {
                         syslog(LOG_WARNING, $message);
                     } else {
                         if ($level->isGreaterOrEqual(Ideasa_Log4php_LoggerLevel::getLevelInfo())) {
                             syslog(LOG_INFO, $message);
                         } else {
                             if ($level->isGreaterOrEqual(Ideasa_Log4php_LoggerLevel::getLevelDebug())) {
                                 syslog(LOG_DEBUG, $message);
                             } else {
                                 if ($level->isGreaterOrEqual(Ideasa_Log4php_LoggerLevel::getLevelTrace())) {
                                     syslog(LOG_DEBUG, $message);
                                     // No trace level in syslog
                                 }
                             }
                         }
                     }
                 }
             }
         }
         closelog();
     } else {
         echo "DRY MODE OF SYSLOG APPENDER: " . $message;
     }
 }
 /**
  * @param Ideasa_Log4php_LoggerLoggingEvent $event
  * @return string
  */
 public function format(Ideasa_Log4php_LoggerLoggingEvent $event)
 {
     $sbuf = PHP_EOL . "<tr>" . PHP_EOL;
     $sbuf .= "<td>";
     $sbuf .= $event->getTime();
     $sbuf .= "</td>" . PHP_EOL;
     $sbuf .= "<td title=\"" . $event->getThreadName() . " thread\">";
     $sbuf .= $event->getThreadName();
     $sbuf .= "</td>" . PHP_EOL;
     $sbuf .= "<td title=\"Level\">";
     $level = $event->getLevel();
     if ($level->equals(Ideasa_Log4php_LoggerLevel::getLevelDebug())) {
         $sbuf .= "<font color=\"#339933\">{$level}</font>";
     } else {
         if ($level->equals(Ideasa_Log4php_LoggerLevel::getLevelWarn())) {
             $sbuf .= "<font color=\"#993300\"><strong>{$level}</strong></font>";
         } else {
             $sbuf .= $level;
         }
     }
     $sbuf .= "</td>" . PHP_EOL;
     $sbuf .= "<td title=\"" . htmlentities($event->getLoggerName(), ENT_QUOTES) . " category\">";
     $sbuf .= htmlentities($event->getLoggerName(), ENT_QUOTES);
     $sbuf .= "</td>" . PHP_EOL;
     if ($this->locationInfo) {
         $locInfo = $event->getLocationInformation();
         $sbuf .= "<td>";
         $sbuf .= htmlentities($locInfo->getFileName(), ENT_QUOTES) . ':' . $locInfo->getLineNumber();
         $sbuf .= "</td>" . PHP_EOL;
     }
     $sbuf .= "<td title=\"Message\">";
     $sbuf .= htmlentities($event->getRenderedMessage(), ENT_QUOTES);
     $sbuf .= "</td>" . PHP_EOL;
     $sbuf .= "</tr>" . PHP_EOL;
     if ($event->getNDC() != null) {
         $sbuf .= "<tr><td bgcolor=\"#EEEEEE\" style=\"font-size : xx-small;\" colspan=\"6\" title=\"Nested Diagnostic Context\">";
         $sbuf .= "NDC: " . htmlentities($event->getNDC(), ENT_QUOTES);
         $sbuf .= "</td></tr>" . PHP_EOL;
     }
     return $sbuf;
 }