Hello NG,
I'm working on a larger C++ project with it's own debug functionality. The
typical debug call looks like this:
DEBUG(WARNING, "An error " << getErrorCategory() << " occured.");
The debug API consists of some complex macros. The macro aquires a debug
stream and pipes the second argument into that stream.
For several reasons I'm trying to get rid of those macros and replace them
with ordinary functions.
The problem: I can't refactor all debug calls. So the function should b
able to take arguments exactly like the makro above:
dbg::debug(WARNING, "An error " << getErrorCategory() << " occured.");
Any chance to make this happen? Somehow I must convince the compiler to
convert "An error " into some kind of object before streaming the rest of
the expression.
Transforming the whole mess into something nicer like
dbg::debug(WARNING) << "An error " << getErrorCategory() << " occured.";
But this wouldn't work, because I have to lock the stream for the complete
write, free the lock after writing the last item and flush the stream...
Any ideas?
Thanks
Thomas