Longman\TelegramBot\TelegramLog::endDebugLogTempStream PHP Method

endDebugLogTempStream() public static method

Write the temporary debug stream to log and close the stream handle
public static endDebugLogTempStream ( string $message = '%s' )
$message string Message (with placeholder) to write to the debug log
    public static function endDebugLogTempStream($message = '%s')
    {
        if (self::$debug_log_temp_stream_handle !== null) {
            rewind(self::$debug_log_temp_stream_handle);
            self::debug(sprintf($message, stream_get_contents(self::$debug_log_temp_stream_handle)));
            fclose(self::$debug_log_temp_stream_handle);
            self::$debug_log_temp_stream_handle = null;
        }
    }

Usage Example

Beispiel #1
0
 /**
  * Download file
  *
  * @param Entities\File $file
  *
  * @return boolean
  */
 public static function downloadFile(File $file)
 {
     $path = $file->getFilePath();
     //Create the directory
     $loc_path = self::$telegram->getDownloadPath() . '/' . $path;
     $dirname = dirname($loc_path);
     if (!is_dir($dirname) && !mkdir($dirname, 0755, true)) {
         throw new TelegramException('Directory ' . $dirname . ' can\'t be created');
     }
     $debug_handle = TelegramLog::getDebugLogTempStream();
     try {
         $response = self::$client->get('/file/bot' . self::$telegram->getApiKey() . '/' . $path, ['debug' => $debug_handle, 'sink' => $loc_path]);
     } catch (RequestException $e) {
         throw new TelegramException($e->getMessage());
     } finally {
         //Logging verbose debug output
         TelegramLog::endDebugLogTempStream("Verbose HTTP File Download Request output:\n%s\n");
     }
     return filesize($loc_path) > 0;
 }
All Usage Examples Of Longman\TelegramBot\TelegramLog::endDebugLogTempStream