0

I'm creating a console application in C++, and for this the user is interacting with the window in different ways (for which I use ncurses). At the same time, I need some way to show system messages during debug (especially), but that would disrupt the user experience, so how to create a logging functionality that preferably prints to another window or something. How can I achieve this?

I'm compiling in the terminal, so I don't have a lot of fancy services of an IDE.

Edit: I'm using a Mac.

Paul R
  • 208,748
  • 37
  • 389
  • 560
BobaFettus
  • 11
  • 1

1 Answers1

0

Open a terminal window and get the name with

$ tty
/dev/pts/3

Open another terminal window. When you write to this file, e.g. /dev/pts/3, the output is printed in the first terminal. You can start your program and pass this filepath as command line argument. Your program writes the debug messages to this file. This way you can separate different types of input and output on different terminal window.

GDB has this feature. You can set --tty=TTY.

Use TTY for input/output by the program being debugged.

Thomas Sablik
  • 16,127
  • 7
  • 34
  • 62
  • That's an interesting solution (from my perspective), but it seems a bit arduous if I have to manually copy and paste every time I run the program – BobaFettus May 08 '20 at 10:24
  • @BobaFettus Maybe there is a way to automatically open a new terminal window and use it. The way I described in my answer is the way other programs solve this problem. – Thomas Sablik May 08 '20 at 10:26
  • You mean something like: https://stackoverflow.com/a/20847541 ? – BobaFettus May 08 '20 at 10:33