Getting print, warn and error output into custom GUI

I would like to be able to get console output into a custom GUI or at least into a script.
This would be useful for a future debugging tool i am planning to make.
If possible, could someone send me a snippet of code that could be used for this.

Thanks in advance.

Thanks a lot, didn’t realise that was a service!