add new function for efficient debug logging