Add logging logic