Fix error in logging function
Run in daemon mode so thread quits when python does