Formatter::format PHP Méthode

format() public méthode

Handles a message.
public format ( integer $code, string $message ) : void
$code integer Log level code.
$message string Message to handle.
Résultat void
    public function format($code, $message)
    {
        switch ($code) {
            case Logger::DEBUG:
                $str_code = 'DEBUG';
                break;
            case Logger::INFO:
                $str_code = 'INFO';
                break;
            case Logger::WARNING:
                $str_code = 'WARNING';
                break;
            case Logger::ERROR:
                $str_code = 'ERROR';
                break;
            case Logger::CRITICAL:
                $str_code = 'CRITICAL';
                break;
        }
        return psprintf($this->_format, ['date' => date(LOGGER_DATE_FORMAT), 'message' => $message, 'code' => $code, 'str_code' => $str_code]);
    }

Usage Example

 /**
  * Format the link.
  *
  * @param Link $link
  *
  * @return bool
  */
 public final function format(Link $link)
 {
     $formatted = $this->formatting($link);
     if (empty($formatted)) {
         // the link has not been formatted by this formatter, try next formatter
         if (!is_null($this->successor)) {
             $formatted = $this->successor->format($link);
         }
     }
     return $formatted;
 }
All Usage Examples Of Formatter::format