factor out _setup_logging in test.py

Extract all the logging related setup calls into a separate method in
test.py. This includes providing context in the docstring for why we
do these things.

It also changes the WARN level overrides to only happen if we are
running > DEBUG, if we actually were running with the OS_DEBUG
override one would expect everything to be running at the DEBUG level.

Change-Id: I4ce3967f2ed4143ba2a1c78606604e1edc2e818e
Merge "factor out _setup_logging in test.py"