Longman\TelegramBot\TelegramLog::error PHP Method

error() public static method

Report error log
public static error ( string $text )
$text string
    public static function error($text)
    {
        if (self::isErrorLogActive()) {
            self::$monolog->error($text);
        }
    }

Usage Example

 /**
  * Get weather string from weather data
  *
  * @param array $data
  *
  * @return string
  */
 private function getWeatherString(array $data)
 {
     try {
         if (!(isset($data['cod']) && $data['cod'] === 200)) {
             return '';
         }
         //http://openweathermap.org/weather-conditions
         $conditions = ['clear' => ' ☀️', 'clouds' => ' ☁️', 'rain' => ' ☔', 'drizzle' => ' ☔', 'thunderstorm' => ' ⚡️', 'snow' => ' ❄️'];
         $conditions_now = strtolower($data['weather'][0]['main']);
         return sprintf('The temperature in %s (%s) is %s°C' . "\n" . 'Current conditions are: %s%s', $data['name'], $data['sys']['country'], $data['main']['temp'], $data['weather'][0]['description'], isset($conditions[$conditions_now]) ? $conditions[$conditions_now] : '');
     } catch (Exception $e) {
         TelegramLog::error($e->getMessage());
         return '';
     }
 }
All Usage Examples Of Longman\TelegramBot\TelegramLog::error