Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I dump TRACE to a file

Status
Not open for further replies.

bulgakov

Programmer
Apr 24, 2003
26
0
0
GB
I know there is a TRACE function/macro that will dump
the stack trace out to the output window in the debugger,
what I want to do is dump the results to a file (as I
will be running a debug build but not with the debugger).
I have chosen not to run a release build because the
TRACE function/macro doesn't work in release mode (obviously).

Thanks.

Marcus.
 
You could do it with a macro and it should work in both

#ifdef TRACE
#undef TRACE
#define TRACE(x) { CStdioFile f; f.Open("myDebugFile.txt",CFile::modeWrite|CFile::modeCreate|CFile::modeNoTruncate); f.SeekToEnd(); f.WriteString(x); }

Or something along those lines. This version of trace will not do any formatting so you need to pass it a string. You can add a "\n" to the end of it for formatting purposes.

Matt

P.S. Code is untested and should most likely remain only available in debug.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top