Monolog\Logger::err PHP Method

err() public method

This method allows to have an easy ZF compatibility.
public err ( string $message, array $context = [] ) : boolean
$message string The log message
$context array The log context
return boolean Whether the record has been processed
    public function err($message, array $context = array())
    {
        return $this->addRecord(self::ERROR, $message, $context);
    }

Usage Example

Beispiel #1
0
 public function __construct(\Niysu\Server $server, \Monolog\Logger $log = null)
 {
     // creating the loader
     $this->filesystemLoader = new \Twig_Loader_Filesystem([]);
     $loader = new \Twig_Loader_Chain([$this->filesystemLoader, new \Twig_Loader_String()]);
     // creating twig
     $this->twig = new \Twig_Environment($loader, []);
     // the "path" function
     // TODO: log when something wrong happens
     $pathFunction = function ($name, $params = []) use($server, $log) {
         $route = $server->getRouteByName($name);
         if (!$route) {
             $log->err('Unable to find route named ' . $name . ' in Twig template');
             return '';
         }
         if (!isset($params) || !is_array($params)) {
             $params = [];
         }
         try {
             return $route->getURL($params);
         } catch (\Exception $e) {
             $log->err('Unable to build route URL for ' . $name . ' in Twig template', ['params' => $params]);
             return '';
         }
     };
     // registering functions
     $this->twig->addFunction(new \Twig_SimpleFunction('path', $pathFunction));
     $this->twig->addFunction(new \Twig_SimpleFunction('url', $pathFunction));
 }
All Usage Examples Of Monolog\Logger::err