Forum Discussion
tristaanogre
Esteemed Contributor
I don't typically like global variables that need to be edited in code. But that, essentially, is what you need to do.
Now, you can probably make it more dynamic as you asked that, in the event handler, you'd call another function that would check the current error with the last error and, if they match, just don't log anything and increment some sort of counter. So, rather than the opening code of if (!lockErrors) return; you would add some additional code before the return to do those little updates and move on. And you would set the lockErrors variable based upon some other code that is executed rather than it being a hard coded value at the top of your unit.
Now, you can probably make it more dynamic as you asked that, in the event handler, you'd call another function that would check the current error with the last error and, if they match, just don't log anything and increment some sort of counter. So, rather than the opening code of if (!lockErrors) return; you would add some additional code before the return to do those little updates and move on. And you would set the lockErrors variable based upon some other code that is executed rather than it being a hard coded value at the top of your unit.
bbi
9 years agoContributor
The algorithm of my event handler is (give it for other people if they can grab ideas):
Same MessageText than previous message ? Yes-> increment repetition counter and lock this Log.Error No -> Check if error message is a known-to-be-ignored one ? Yes-> make a Log.Message instead of a Log.Error and lock this Log.Error No -> Check if repetition message counter is > 0 ? Yes-> as the message has changed then make a unique Log.Message for the repeated message Make a Log.Error entry and reset repetition counter as well as previous message backup and lock this Log.
So after your interesting replies i think i'll keep my solution for now.
The global variable solution works well also but need more lines of code and add external variable.
The splitting method is ok also but add another function. Perhaps it's the more elegant because adding more flexibility but it's the heavier.
Txs for your ideas.
Related Content
- 8 years ago
- 13 years ago
Recent Discussions
- 2 days ago
- 7 days ago
- 11 days ago