I don't know what to use as the type of the return value and the parameter. I thought about using a template; but then won't I have to do something like log <std::string><< "Hello!";?
It works with polymorphism but I can't do log << "Hello" << ", world!";; I would have to do log << "Hello, world!"; instead, whereas with std::cerr you can do the former. How can I do this?
@Seraphimsan,
Wow, really? What are you writing? I need a logging function for my emulator so that later on people will be able to tell exactly what caused that damn triple fault.
Nice *takes note of all this* and chrisname I'm writing a video game. But I'm likely going to put that in a header in my includes folder for MinGW...cause I often have use of an error reporting system.
Well, the method above works very well for me. I'm not sure of the performance hit of calling operator<< 3 times on everything (ofstream and ostream's operator<< overloads are called too) but R0mai's method is easy to understand and extensible. Thanks for the suggestion, but I think I'm going to stick to the above. If I needed (for whatever reason) more than one logfile, it would be very easy to add one...
Thanks anyway, Duoas.
Edit: Boost isn't standard yet, anyway, is it? A design goal of the program is to have as few unreasonable* dependencies as possible (at the moment, three (SeaBIOS, VGABIOS and SDL)); and I won't add anything to the list unless I have to. As the class in place already does everything I need, I don't see it as being necessary to add Boost to my list of dependencies.
*an "unreasonable dependancy" being one that you couldn't reasonably expect someone wanting to compile your program to have.