Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print to output (not stdout) in Linux (GCC)?

Tags:

c++

linux

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.

like image 484
Violet Giraffe Avatar asked Dec 04 '22 06:12

Violet Giraffe


1 Answers

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).

like image 155
Fred Foo Avatar answered Dec 05 '22 19:12

Fred Foo