c++ Programming Glossary: clog.rdbuf
Redirect C++ std::clog to syslog on Unix http://stackoverflow.com/questions/2638654/redirect-c-stdclog-to-syslog-on-unix int log_priority return os In main I initialize clog std clog.rdbuf new Log foo LOG_LOCAL0 Then whenever I want to log it's easy..
redirect std::cout to a custom writer http://stackoverflow.com/questions/533038/redirect-stdcout-to-a-custom-writer clog use the buffer from oss std streambuf former_buff std clog.rdbuf oss.rdbuf std clog This will appear in oss std flush std cout.. cout oss.str ' n' Give clog back its previous buffer std clog.rdbuf former_buff return 0 so in a mainloop I will do something like.. MySink sb sb.open MySink std streambuf oldbuf std clog.rdbuf sb std clog hello world std endl std clog.rdbuf oldbuf return..
How to redefine clog to tee to original clog and a log file? http://stackoverflow.com/questions/937805/how-to-redefine-clog-to-tee-to-original-clog-and-a-log-file has the same rdbuf as clog so the following has no effect clog.rdbuf myTee.rdbuf So how can I modify the tee class to have its own.. can do this fstream logFile ... TeeBuf tbuf logFile.rdbuf clog.rdbuf clog.rdbuf tbuf For more information on how to derive your own.. fstream logFile ... TeeBuf tbuf logFile.rdbuf clog.rdbuf clog.rdbuf tbuf For more information on how to derive your own streambuf..
|