Add logging function