Added better logging format, added console logging in debug mode.