Correctly restore warning capture after logging tests.

This is a fix to the wrong behavior that 15c3906eeb introduced.