CSFML icon indicating copy to clipboard operation
CSFML copied to clipboard

Add a way to capture error messages.

Open SpaceManiac opened this issue 9 years ago • 3 comments

For languages with error handling facilities, it would be useful to be able to capture messages output to sf::err() from CSFML. I suggest an API like:

sfErrorCapture* sfErrorCapture_start();
const char* sfErrorCapture_get(const sfErrorCapture* capture);
void sfErrorCapture_end(sfErrorCapture* capture);

I tried to implement this myself using std::ostringstream, but it seems like something is going odd in linking and each CSFML module has its own copy of the sf::err function, so placing these functions in the system module means that errors from other modules are not redirected.

SpaceManiac avatar May 22 '15 22:05 SpaceManiac

I support this.

oprypin avatar Aug 23 '15 14:08 oprypin

Error handling will completely change in a future version of SFML, and as you pointed, there are multiple sf::err streams in CSFML, so there's no easy solution.

LaurentGomila avatar Aug 23 '15 17:08 LaurentGomila

It would be possible to add a function to each module to redirect the output into a single stream. Trouble with that approach is that if SFML is dynamically linked then sf::err will be set multiple times and it would be redundant. But that could be avoided with a few simple processor commands at compile time.

zsbzsb avatar Nov 06 '15 17:11 zsbzsb