any use for SDL user events besides error handling?
I've set up a simple error reporting system using custom events. The user event structure was used in the following way: code : severity of error (from an enum: info, warning, error, critical, fatal) data1 : string containing name of the system that sends the message data2 : string containing a description of the issue Now the thing is i've just hogged all user events by doing this. Will I miss them later on development? what other uses can they have? (besides sending an exit message to the main loop?)
Working on a fully self-funded project
One idea is wouldn't you rather just log everything instead? I was first thinking about making my own error handling system using messages and with custom logging and all - then I stumbled upon the free logger class from Fluid Studios. All you have to do is put
Now as for SDL user events use. I really do not think so. I mean most of anything you could want to do can be accompished through other ways rather than filling up the message queue. It's kind of like the windows WM_USER events. You might only use them for like one or two things once in a blue moon, and that's it. If you decide to use them all up now, I would highly doubt it could come back and haunt you. I could not really think of anything other than error handling off the top of my head right now.
- Drew
LOG("String Here");
And that's it! If you are going to abort or exit, then you might want to close the log file first though. This is just some comments about error handling, feel free to do it however you want though - I know you are not asking about error handling, but wanted to let you know of a great tool you could use. [smile].Now as for SDL user events use. I really do not think so. I mean most of anything you could want to do can be accompished through other ways rather than filling up the message queue. It's kind of like the windows WM_USER events. You might only use them for like one or two things once in a blue moon, and that's it. If you decide to use them all up now, I would highly doubt it could come back and haunt you. I could not really think of anything other than error handling off the top of my head right now.
- Drew
in mine you go
and you get this in the log:
=) the only detail is that once you do SDL_Quit, you can't keep using it.
Log(warning,"OpenGL","X happened");
and you get this in the log:
Warning from module OpenGL: X happened
=) the only detail is that once you do SDL_Quit, you can't keep using it.
Working on a fully self-funded project
Quote:
Original post by Madster
in mine you goLog(warning,"OpenGL","X happened");
and you get this in the log:Warning from module OpenGL: X happened
=) the only detail is that once you do SDL_Quit, you can't keep using it.
[smile] Awesome! Right now in my audio library I mixed the logging with lots and lots of aborts [lol]. So if something goes wrong, you sure as heck are gonna know it! In my last library I did something similar to what you have done. I made a macro function that let me specify the log level, custom error message, and a remedy. If I specified release version, everything was compiled out to save speed and efficiency, for that logger sure does add some size. That is one good thing about making your own though. If I only had the time... Good luck on your project!
- Drew Benton
It was really simple... might as well explain it, turned out much simpler than i thought it would.
Just tossed a global function Log that shoves the event in the SDL queue
and then tossed another global function that looks for the custom event: something like LogErrorEvent(const SDL_Event *event)
and it logs to cerr parsing with a simple switch structure.
Took about 15 minutes to code. Really. Took me longer to figure out some silly dependencies i had. Winded up tossing them in their own namespace in their own file pair (.cpp .h)
The only detail with it is that you gotta remember that SDL_Quit jumps at the front of the queue, and during shutdown you gotta keep processing events so if there's any errors they get logged. Im still thinking about that one. Ideas would be appreciated ;)
Just tossed a global function Log that shoves the event in the SDL queue
and then tossed another global function that looks for the custom event: something like LogErrorEvent(const SDL_Event *event)
and it logs to cerr parsing with a simple switch structure.
Took about 15 minutes to code. Really. Took me longer to figure out some silly dependencies i had. Winded up tossing them in their own namespace in their own file pair (.cpp .h)
The only detail with it is that you gotta remember that SDL_Quit jumps at the front of the queue, and during shutdown you gotta keep processing events so if there's any errors they get logged. Im still thinking about that one. Ideas would be appreciated ;)
Working on a fully self-funded project
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement