If you read the code, you will notice that the FIRST time this error is encountered, it will always be logged.
The test in question is done frequently, and subsequent failures are about 100 times less interesting than the first. Unless you just like filling up disks with log files while your network is acting up.
Finally, note that the "_ok" flag will be RESET and the resolved condition logged once the test finally returns to succeeding.
I strongly dislike your version. Creating a boolean just to use and discard in the next line? Twice? Ugly. I'd much rather keep the code simple and try to cut out confusing parts. Give the flag a better name and remove the useless ternary. I'd also get rid of the conditional return and let the one outside the catch do the work.
I'd tend to choose temporary variables. I trust my compiler to optimise them out, and I find it makes it much easier to find the appropriate place to change or add new code.
"Does this affect working out whether the error has been logged before?", "Does this affect whether we should log this error?", etc
EDIT: But in this case I'd still want to put a comment clarifying the "why".
I commented earlier, but I can't get over how ridiculous that line is. If you started by just writing the intent (!ok && rand() > .1) you actually have to work really hard to turn it into what you have there, and introduce a bug in the process.
If an exception was thrown, and _ok evaluates to false, then approximately 10% of the time, log the exception to the error log. Probably just to cut down on noise in the logs, or to account for brief periods of latency where the server appears down, but isn't.
I think that you're right about the intent of the author, but unless I'm mistaken, that's not what the code does. If _ok is false, it boils down to
if(!(Math.random() > 0.1))) which is the same as if(Math.random() <= 0.1), which means it will return early only 10% of the time, so the exception gets logged 90% of the time.
The test in question is done frequently, and subsequent failures are about 100 times less interesting than the first. Unless you just like filling up disks with log files while your network is acting up.
Finally, note that the "_ok" flag will be RESET and the resolved condition logged once the test finally returns to succeeding.