Use threading for logging