Migrate from printf to streams in my logfile class.
-
Hello I've written a logfile class that writes the logentries in xml format. A typical usage: mylog.WriteLog(LOG_PRIO_HIGH, "Agroup", "This is a text with %d some %s vars", 34, "diffrent"); output <entry date="2003-01-01" time="20:01:32:1234" prio="1" group="Agroup">This is a text with 39 some diffrent vars</entry> I want to accomplish the same thing by using streams/stringbuf. But I've not found any good examples that show me how I should do. What i've found is a couple of examples that derives a class from stringbuf and from ostream. I would be nice of I can get something like this: log << log_prio(1) << log_group("test") << "hello" << nIntVar << strBuf << log_end; log << "this is a string"; log << " something more" << log_end; log << log_prio(2) << "last line" << log_end; would look like: <entry date="2003-01-01" time="20:01:32:1234" prio="1" group="test">hello1yeye</entry> <entry date="2003-01-01" time="20:01:32:2200" prio="1" group="test">this is a string something more</entry> <entry date="2003-01-01" time="20:01:32:6600" prio="2" group="test">last line</entry> How do I accomplish this? Thanks, Jonas