Debug messages are typically unbuffered or "line buffered".   If that is truly causing a performance problem AND you still want to collect the messages -- you'll need to find a better way to channel and collect those messages.