Moved all logging to one function.