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. PS And syslog
is no different.
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)
.
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.