Correct logging within thread without dialog
Correct logging within thread without dialog
Hi,
I'm a EurekaLog user that has given up on it, due to some many bugs, and I'm evaluating madExcept before I buy it.
The problem I need to solve is detailed on stackoverflow at the link below:
https://stackoverflow.com/questions/466 ... -eurekalog
Of course, there I tried to solve it with EurekaLog, but I wasn't successful. Using madExcept, the dialog box is appearing when I have a log within the thread also, but I want it to appear only if I have an exception on the main thread; errors on any background threads I want to just log the error with the complete bug report, and no dialog box. Can this be accomplished?
Thanks
I'm a EurekaLog user that has given up on it, due to some many bugs, and I'm evaluating madExcept before I buy it.
The problem I need to solve is detailed on stackoverflow at the link below:
https://stackoverflow.com/questions/466 ... -eurekalog
Of course, there I tried to solve it with EurekaLog, but I wasn't successful. Using madExcept, the dialog box is appearing when I have a log within the thread also, but I want it to appear only if I have an exception on the main thread; errors on any background threads I want to just log the error with the complete bug report, and no dialog box. Can this be accomplished?
Thanks
Re: Correct logging within thread without dialog
Hi there,
you can do something like this:
This should behave as if the user pressed the "continue application" in the exception box for thread exceptions. Hope that's what you were looking for? The crashed thread will then usually just die, but the application itself should continue to run.
Of course, generally it's a question worth asking if it's a good idea to let your application continue running if there was a crash in a secondary thread. E.g. if the secondary thread has opened some files or entered some critical sections, and then crashes without releasing all that, your application might not be in a safe state to continue running. So maybe you want to use "exceptIntf.AutoRestart := true" instead of "AutoContinue := true"? But I'll leave that decision up to you. If you prefer letting your application continue, then please double check all your threading code and make sure you add "try..finally..end" blocks everywhere to properly release all resources and lock mechanisms in case of an exception.
you can do something like this:
Code: Select all
uses madExcept;
procedure SilenceThreadExceptions(const exceptIntf: IMEException; var handled: boolean);
begin
if exceptIntf.CrashedThreadId <> MainThreadId then
begin
// secondary thread
exceptIntf.GeneralShowSetting := ssNothing;
exceptIntf.AutoContinue := true;
end;
end;
initialization
RegisterExceptionHandler(SilenceThreadExceptions, stDontSync, epQuickFiltering);
end.
Of course, generally it's a question worth asking if it's a good idea to let your application continue running if there was a crash in a secondary thread. E.g. if the secondary thread has opened some files or entered some critical sections, and then crashes without releasing all that, your application might not be in a safe state to continue running. So maybe you want to use "exceptIntf.AutoRestart := true" instead of "AutoContinue := true"? But I'll leave that decision up to you. If you prefer letting your application continue, then please double check all your threading code and make sure you add "try..finally..end" blocks everywhere to properly release all resources and lock mechanisms in case of an exception.
Re: Correct logging within thread without dialog
Thanks for the reply. I'll try your code tonight, and I'll post the results.
My software is in beta mode, and the background threads execute some background syncing. I'm getting some really sparse errors (after 5 days working, I get an error), and at first I just want to receive the report, to avoid interfering with the front-end activities.
Looks like you're getting a new customer.
Thanks again
My software is in beta mode, and the background threads execute some background syncing. I'm getting some really sparse errors (after 5 days working, I get an error), and at first I just want to receive the report, to avoid interfering with the front-end activities.
Looks like you're getting a new customer.
Thanks again
Re: Correct logging within thread without dialog
With the code that you made available, will the error report be sent automatically via email? If not, what would I need to accomplish this, please? A link to a sample code would suffice.
Thank you so much.
Thank you so much.
Re: Correct logging within thread without dialog
Depends on your settings. If auto emailing is globally enabled, then it should work. If it's globally disabled, you can enable it for the secondary thread exceptions by doing "exceptIntf.AutoSend := true" in your exception handler.
Re: Correct logging within thread without dialog
Awesome.
So much better than EurekaLog.
Tks
So much better than EurekaLog.
Tks
Re: Correct logging within thread without dialog
It worked great.
The only thing that was weird is that, after I implemented this code, the bug reports stopped being sent on the background. The icon shows up that it's sending, and I don't get an error, but it's not sent for some reason. Since I already had the code to send bug reports using email, I just hocked it up with my code, and out it went.
Fantastic work. I'm gonna make some more tests and I'll purchase madExcept.
Tks
The only thing that was weird is that, after I implemented this code, the bug reports stopped being sent on the background. The icon shows up that it's sending, and I don't get an error, but it's not sent for some reason. Since I already had the code to send bug reports using email, I just hocked it up with my code, and out it went.
Fantastic work. I'm gonna make some more tests and I'll purchase madExcept.
Tks
Re: Correct logging within thread without dialog
Great - thanks!