Add log function to debug the code.