0

I want to catch the verbose data which is printed to STDERR in Libcurl (C++). However, I can only point to a file when I want to change CURLOPT_STDERR. Of course, I could point to a file, dump the data, read the file and remove the file, but that seems a bad routine?

Besides that, I'm aware of the CURLOPT_DEBUGFUNCTION which gives me back bad formatted strings with weird newlines at the end which I can't replace for my logging.

So, how can I catch the clean data (as shown by STDERR) from the CURLOPT_VERBOSE function?

TVA van Hesteren
  • 1,031
  • 3
  • 20
  • 47
  • You might have something like `fmemopen` to create a `FILE*` from a memory buffer. Then when done you read this memory buffer. Of course, you have to preallocate the buffer, and make it big enough for all data written to it. – Some programmer dude Mar 27 '17 at 13:47
  • `CURLOPT_DEBUGFUNCTION` gets the exact same logging and is the designed way to catch the verbose info without using a FILE * to direct them to. You must be doing something wrong there... – Daniel Stenberg Mar 28 '17 at 10:51
  • @Daniel, indeed, however the strings are formatted with a new line on each line which I can't replace and it breaks my logging logic which makes it overloaded with new lines – TVA van Hesteren Mar 29 '17 at 05:45
  • So don't log the newlines? and btw, the verbose text you'd be able to catch from stderr *also* has newlines... – Daniel Stenberg Mar 29 '17 at 06:46
  • Well, if you can tell me how not to log the newlines.. it aren't normal \n or \r\n characters – TVA van Hesteren Mar 29 '17 at 09:32

0 Answers0