View Single Post
cout, cerr and clog in HL
Old
  (#1)
koraX
Member
 
koraX's Avatar
 
Status: Offline
Posts: 145
Join Date: Jan 2004
Location: Slovak Republic
Default cout, cerr and clog in HL - 01-09-2004

Does anybody know if Half-life is using these standard streams ? (cout, cerr and clog)

I'm asking because I want to redirect them to files and use them for logging and debuging purposes in my bot.
If HL used them, I could cause mess by redirecting them.

Also If someone is interested in redirecting, heres how it works :
Code:
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
	clog << "Output to screen" << endl;

	ofstream mFile;
	streambuf *oldbuf=clog.rdbuf();

	mFile.open("filename.log");
	if(mFile) {
		if(mFile.rdbuf()->pubsetbuf(NULL,4096)==false)
			cerr << "error : cannot resize file buffer for clog" << endl;
		clog.rdbuf(mFile.rdbuf());
	}

	clog << "Output to file" << endl;

	// ...

	clog.flush();
	clog.rdbuf(oldbuf);
	mFile.close();
	clog << "Output back to screen" << endl;
	return 0;
}


kXBot
koraX's utils
- see my homepage for other projects (OpenGL CSG Editor, FAT16 Sim, NNetwork Sim, ...)
  
Reply With Quote