You might be interested in this post. I've implemented a message tracer with an extra feature to send messages to the debug panel. More details at the package readme.