Refactor log thread into separate class

This moves the logic for the logger thread into a separate class and moves
the communication into a local BroadcastReceiver.