handling writing to log