Re: DEBUGMSG : output to a file

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



This is a little crude but its easy to add to a number of drivers etc, what
i do is overrider the RETAIL/DEBUG msg macro and plug in my own writing to a
file, the advantage of this is that you can see the log after a reboot or as
part of a shutdown without having a debug cable / serial port.

So:

extern void myLogPrnt( const WCHAR* wszFormat, ... );
#define RETAILMSG(a,b) {myLogPrnt b;}

Then define in the module somewhere:

FILE* gLogFile = NULL;
WCHAR wszBuffer[4096];
void myLogPrnt( const WCHAR* wszFormat, ... )
{
int nCount;
va_list args;

// Write formatted string
va_start( args, wszFormat );
nCount = _vsnwprintf( wszBuffer, 10024, wszFormat, args );
va_end( args );

// Check for buffer exceed length
if( -1 == nCount )
{
nCount = 4096 - 1;
wszBuffer[nCount] = 0;
}

// log to file
gLogFile = _wfopen( L"\\log.txt", L"a" );
fseek(gLogFile, SEEK_END, 0);
fwprintf(gLogFile, L"%d:%s", GetTickCount(), wszBuffer);
fclose(gLogFile);
}

This prints out the tick count as well otherwise you have no idea about the
speed the debug was being produced

--
--
GraemeW
Blog - http://ce4all.blogspot.com

"mosfet" <john.doe@xxxxxxxxxxxxx> wrote in message
news:477b6eb8$0$5362$426a74cc@xxxxxxxxxxxxxxx
Hi,

Is there any standard way to output debug trace (DEBUGMSG) into a file ?
I would like to debug the sms provider .







.



Relevant Pages

  • Re: Direct interaction with subprocess - the curse of blocking I/O
    ... Either no comment here or say _why_ it is empty. ... I'd not hide the details of the exception like that. ... if DEBUG: ... print(format_str % (args or kwargs)) ...
    (comp.lang.python)
  • Re: RCR debug
    ... puts if $DEBUG ... <do something incredibly smart with the args;)> ... I much prefer the fine grained control that the 'logging' and 'log4r' ...
    (comp.lang.ruby)
  • Re: any macro-like construct/technique/trick?
    ... doing a no-op call or checking if the callback function doesn't exist. ... def debug_emit(klass, *args): ... if debug: ...
    (comp.lang.python)
  • Re: Commandline Argument Array Help
    ... You can go into the Assembly Properties, and under the DEBUG section, you ... The esiest way I've found of doing Command Line Args is use a module as your ... Public Sub Main) ...
    (microsoft.public.dotnet.languages.vb)