My test application writes logs in
stderr and uses
stdin to receive interactive commands from the user. Needless to say, that any
stderr output spoils user input (and command prompt) in terminal. For example, this command line (
_ is a cursor position):
Command: reboo04-23 20:26:12.799 52422 2563 D firstname.lastname@example.org:27 started _
To fix that, I want to have something like old Quake console, where logs go one line above the current input line. In other words, I want to get that instead:
04-23 20:26:12.799 52422 2563 D email@example.com:27 started Command: reboo_
I can modify both logging code and code that reads user input. Want that to work for Linux and OS X.
log() function could be invoked from different thread. The
log() function is the only writer to
Other suggestion to fix that problem (spoiled input line) are welcome. I’m looking for a solution that could be implemented without additional libraries (like Curses). I tried to google that up, but realized that I need a sort of idiomatic kickoff to understand what exactly I want.
Thanks to Jonathan Leffler comment I realized that I also should mention that separating
stdout is no that important. Since I control the
log() function it’s not a problem to make it write to
stdout instead of
stderr. No sure whether it makes the task easier or not, though.