Capture debug logs when testing.

Add an ability to test the most recent log message,
no matter what is its level.