make logging threadsafe