add logging for debug mode