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
Example #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));
 }
Example #2
0
 /**
  * @param PlayzoneMessage $messageObject
  * @param WebsocketUser $wsUser
  */
 private function send(PlayzoneMessage $messageObject, WebsocketUser $wsUser)
 {
     try {
         $this->container->get("ws.handler.client.message")->prepareMessageForUser($messageObject, $wsUser);
         $message = $this->container->get('jms_serializer')->serialize($messageObject, 'json');
         $this->logger->info("Server: " . $message);
         $wsUser->getConnection()->send($message);
     } catch (\Exception $exception) {
         $this->logger->err("Error on send: " . $exception->getMessage() . ' ' . $exception->getFile() . ' ' . $exception->getLine());
         $wsUser->getConnection()->send($exception->getMessage() . ' ' . $exception->getFile() . ' ' . $exception->getLine());
     }
 }
Example #3
0
 private function getAvailability($ids)
 {
     $minRates = array();
     try {
         if ($ids) {
             $minRates = $this->reservitUtils->getAvailability($this->searchData->datePax, $ids);
         }
     } catch (\Exception $e) {
         $this->errors[] = 'search.results.error.reservit';
         $this->logger->err($e->getMessage());
     }
     return $minRates;
 }
Example #4
0
 /**
  * Adds a log record at the ERROR level.
  *
  * @param string $message The log message
  * @param array $context The log context
  * @return Boolean Whether the record has been processed
  */
 public function err($message, array $context = array())
 {
     return $this->_logger->err($message, $context);
 }
Example #5
0
     continue;
 }
 while ($row = mysql_fetch_array($table)) {
     $to_email = $row["to_email"];
     $to_mobile = $row["to_mobile"];
     $to_jid = $row["to_jid"];
     $content = $row["remindcontent"];
     //发送邮件
     if ($to_email != null && !empty($to_email)) {
         $fromname = $row["from_name"];
         try {
             $title = mb_substr($content, 0, 20, 'utf-8');
             $mailtext = \Swift_Message::newInstance()->setSubject($title)->setFrom(array($mailer_user => $fromname))->setTo($to_email)->setContentType('text/html')->setBody($content . "【Wefafa企业协作平台】");
             $mailer->send($mailtext);
         } catch (\Exception $e) {
             $logger->err($e);
         }
     }
     //发送手机短信
     if ($to_mobile != null && !empty($to_mobile)) {
         if ($content != null || !empty($content)) {
             call_user_func("sendMobile", $SMS_ACT, $SMS_PWD, $SMS_URL, $to_mobile, $content . "【发发时代】");
         }
     }
     //发送wefafa消息
     if ($to_jid != null && !empty($to_jid)) {
         $from_jid = $row["from_jid"];
         if ($from_jid != null || !empty($from_jid)) {
             call_user_func("sendMsg", $SERVER_URL, $from_jid, $to_jid, "remind_msg", $content, "", "", "");
         }
     }
 /**
  * Adds a log record at the ERROR level.
  * 
  * This method allows for compatibility with common interfaces.
  *
  * @param string $message The log message
  * @param array $context The log context
  * @return Boolean Whether the record has been processed
  * @static 
  */
 public static function err($message, $context = array())
 {
     return \Monolog\Logger::err($message, $context);
 }
Example #7
0
 /**
  * @param string $message
  * @param array $context
  * @return bool
  */
 public function err($message, array $context = array())
 {
     return parent::err($message, $context);
 }
Example #8
0
 public function error($msg)
 {
     $this->logger->err($msg);
 }
Example #9
0
 /**
  * Runtime errors that do not require immediate action but should typically
  * be logged and monitored.
  *
  * @param string $message
  * @param array  $context
  *
  * @return void
  */
 public function error($message, array $context = array())
 {
     $this->monolog->err($message, $context);
 }