So we have our own log function that already use, it has groups and loglevel (error, warn, info, debug, …), and is able to output to different targets (file, console, …).
I would like to use SDL_LogSetOutputFunction to make SDL logs go through our system (adding a SDL group for them). Problem is our codebase is in C++ and I am a bit unsure how to tie things.
I am also unsure exactly how the function SDL expect should look. Has anyone used it and has any guidance to offer?
If your logging object is dynamically allocated, make sure you call SDL_LogGetOutputFunction() to save the original logging function and reset that with SDL_LogSetOutputFunction() before your logging object is deleted.
If you have a logging function instead of a class, then this is even easier, you can just pass that to SDL_LogSetOutputFunction() and set the userdata parameter to nullptr and ignore it.
Thanks! I think I understand now. I was under the impression I would need to use some of those extern C commands but it seems it’s not needed. I will try and report if it works!