How to intercept stdout to display inside tui layout?

Hi community ! I want to implement UI using tui crate and I have an issue. In my origin crate there a lot of places where I use println! and I want to intercept all that output somewhere to display inside rendered UI.

Could somebody explain if this possible and what better to use for this ? I hope I can avoid of using channels.

With-output-stream ...? discusses a similar issue of capturing/rerouting stdout.

1 Like

If you're willing to limit yourself to Unix systems then you could just redirect stdout to a pipe.

So, the main approach is that we store stdout somewhere and just use once need.
gag is most closest to what I am looking for. Thank you !