Made some changes to logging to better keep track of logs generated from different threads.