code for logging