logfile msg: get method and class names
Hi,
I`ve a logfile which should contain all errors which can occur in the
programm. My document-class (SDI application) will contain a member-
variable of my logfile-class. If a error occurred in a different
thread than the mainthread I will write a PostMessage() to the window
I`ve installed for the document.
It would be great if the logfile will contain the information: class-
name, method-name, function-call with the specific GetLastError() if
available. Are there any methods to get the class name as well as the
method name where the error occurred? So that I immediately know where
the error occured if I see the logfile.
void MyThreadClass::MyMethod()
{
int rtn = Methodcall()
if(rtn != SUCCESS)
{ /* failed -> send msg to logfile */
DWORD err = ::GetLastError();
CString *perr = new CString();
perr->Format(_T("%s | %s | %s - %s"), classname, methodname,
call, err);
/* example:
perr ("MyThreadClass | MyMethod | Methodcall -
20(GetLastError) ")
*/
if(m_wnd)
m_wnd->PostMessage(UWM_LOGFILE_MSG, (WPARAM)perr,
(LPARAM)0);
}
}
Another method is to install thousands of defines (each possible error
will get one of these defines).... but that`s not really a good idea,
because it`s hard to update....
Are there any other options to determine where the error (located in
the logfile) occurred?
best regards
Hans