Adds logging function