houseabsolute / Log-Dispatch

Dispatches messages to one or more outputs
https://metacpan.org/release/Log-Dispatch/
Other
12 stars 29 forks source link

Ensure that $@ and $! are not changed in logging methods #18

Closed salva closed 8 years ago

salva commented 8 years ago

Logging methods shouldn't modify globals. Specially $@ and $!.

salva commented 8 years ago

$! may potentially be changed by any perl built-in and so, identifying all the places where it could be changed and adding more fine grained localizations (as in the $@ case), is not IMO, a viable approach.

I placed it at that particular location because it is just after the performance critical code. So it doesn't slow down logging calls that are skipped but then protects everything else.

I have not run any benchmark, and the cost of localizing $! may well be negligible compared to the _should_log method call, so maybe it would be better to place it just at the subroutine enter.

autarch commented 8 years ago

I ended up merging this from the CLI. Thanks!