tui-rs icon indicating copy to clipboard operation
tui-rs copied to clipboard

[help] Suppressing `println` from other code

Open yatesco opened this issue 5 years ago • 1 comments

Hi - TUI newbie here :-).

I poll my log server for new log messages and unfortunately the client emits printlns which get rendered on top of the TUI. I know it's possible to gag stdout but that seems a very silly thing to do in a TUI!

Is there an idiomatic way of creating a new stdout and piping the println to that?

To be clear, this isn't a separate process, it is:

loop {
  do_tui_rendering_stuff()?;
  refresh_logs();
}

and refresh_logs has printlns.

Other than "well obviously don't use printlns!", what options do I have?

Thanks!

yatesco avatar Nov 07 '20 17:11 yatesco

that's actually more a thing to configure in the backend of your choice. e.g the crossterm example for using stderr is here: https://github.com/crossterm-rs/crossterm/blob/master/examples/stderr.rs

but that only fixes the println obviously. stuff printed to stderr will still be appearing in your tui

extrawurst avatar Dec 08 '20 00:12 extrawurst