5

On Windows there is OutputDebugString function, how do I do the same on Linux?

Update: stderr and stdlog is not what I want. Those are redirected to stdout. P. S. And syslog is no different.

3
  • Which window manager are you using? And is this a console or winodwed application? Commented Dec 4, 2011 at 14:06
  • @johnathon: it's a console app, and I wouldn't like to rely on a certain WM. Commented Dec 4, 2011 at 14:15
  • 1
    std::cerr does not necessarily redirect to stdout. Commented Dec 5, 2011 at 12:10

3 Answers 3

10

I'm not sure what OutputDebugString does exactly, but standard C++ defines the standard error stream std::cerr and the standard logging stream std::clog. Both are declared in the header <iostream>.

These are by default tied to the same file descriptor in Linux; the difference is that cerr is unbuffered, while clog is buffered (I believe it's line-buffered).

There is no notion of a "system debugger" in Linux. If you want to write to the system log, you can use syslog(3).

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you. By the way, what does 3 mean is syslog(3)? I see such a notation often, but can't understand the meaning.
@VioletGiraffe: it means syslog is in section 3 of the Linux manual. man 3 syslog will bring up the manpage for it.
Those are all displayed in the console instead of "output" window in the IDE. Any further ideas?
@VioletGiraffe: check your IDE documentation. I don't use IDEs, so I can't help you further.
5

There is probably no exact equivalent of such a function in Linux or Posix systems.

You could output to stderr (if in C or C++), or to std::cerr or std::clog in C++.

Notice that with most shells, you can start some program and redirect differently and independently their stdout & their stderr.

For system logging, you could use the openlog & syslog functions.

If you want to output to the controlling terminal (if it exists), you could use the /dev/tty device.

Comments

3

qDebug on Linux is redirected to stdout. There is no way to get two distinct output streams as with OutputDebugString on Windows. There appears to be no dedicated debug output stream on Linux.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.