Hi everyone,
I'm trying to make a generic logger class for help with debugging an application I'm working on (project that I can't use any debuggers with for a plethora of reasons).
Anyway, I'm trying to create a simple static class that I can call methods on from within any polymorphic object and have it automatically output the name of the object's class.
This is what I have so far, and it doesn't actually work haha
Code:
string Logger::debugMessage(void *o, string outText)
{
string ret = typeid(o).name()+string(": ")+outText+string(" ");
Logger::OutputText(const_cast<char *>(ret.c_str()));
return ret;
}
The idea is that I call it as such (from within any class - everything I want to test on has virtual methods so typeid shouldnt be a problem I think):
Code:
void someClass::someMethod()
{
macros::debugMessage(this, "calling someMethod");
}
Going through everything and adding a 'typeName' property isn't really an option as far as I see it, I'd much rather do this properly than resort to a hacky method like that.
Thanks for any help
cheers