lotabout / tuikit

Tool kit for writing TUI applications in Rust.
MIT License
104 stars 28 forks source link

[question] Where does Rust's panic/eprintln output go? #29

Closed kneasle closed 3 years ago

kneasle commented 3 years ago

I'm building a fairly complex TUI application on top of tuikit, and so far it's working great. But one thing that's bugging me is that I can't get any debug printing because tuikit seems to be overwriting stdout/stderr. Is there a way to disable/workaround this behaviour?

For debug printing, I plan to add a custom logger anyway, but this issue is a bit of a kicker because I don't get panic messages when my code crashes which would be really useful. But if I could apply the same solution to get debug printing back then that would be great.

lotabout commented 3 years ago

@kneasle The debug messages would go to stderr which would send to stdout by default and could be easily overwritten in TUI applications.

You could try <whatever your commands> 2> some_log_file to catch the error logs. Let me know if it works.

kneasle commented 3 years ago

Oh awesome the piping trick works (though it also eats cargo's output if you use it with cargo run 2> log, but that's fine).

apelisse commented 3 years ago

That probably needs to be documented somewhere, as it seems to consume panics which is frustrating at first. Also, some documentation/example on "restoring" to normal mode would help, I realized one can do term.pause(), but that could be called out specifically somehow?

kneasle commented 3 years ago

Yeah I +1 this - this is a fantastic tool for easily creating tui apps and this slight lack of docs is my only gripe....