clog

Why doesn't my change to clog stick?

I think I'm failing to understand some finer point of C++. I want to set up a log of what my program does, and discovered std::clog, which seems to do what I want in theory, but in practice it doesn't. If I do the following, clog works as expected and writes "Test 1" to the screen, and "Test 2" shows up in a file: int main () { clo...

How to redefine clog to tee to original clog and a log file?

Hello, I saw a useful start here: http://www.cs.technion.ac.il/~imaman/programs/teestream.html And it works great to make a new stream which goes to both clog and a log file. However, if I try to redefine clog to be the new stream it does not work because the new stream has the same rdbuf() as clog so the following has no effect: cl...

How to redefine clog's rdbuf() to be a tee to the original rdbuf() of clog and that of a log file?

Hello, Does anyone have an example of how to redefine the C++ built in clog to instead have a new associated rdbuf() which is processed to be a tee to the original clog.rdbuf() and the rdbuf() of a ofstream object to a log file on disk. The intention is to have the code use the std::clog throughout but to have it go to the both the def...

Redirect C++ std::clog to syslog on Unix

I work on Unix on a C++ program that send messages to syslog. The current code uses the syslog system call that works like printf. Now I would prefer to use a stream for that purpose instead, typically the built-in std::clog. But clog merely redirect output to stderr, not to syslog and that is useless for me as I also use stderr and st...