You can do it easily yourself, e.g. following code will produce a text
stream.

Best regards,
    Jan Slodicka

======= trace.h =======

//
// Trace usage
//
// #define TRACE  // without this the following lines are ignored by
compiler
// #include "trace.h"
//
// open_trace( "MyBackupLog" ) ;
//  trace( char *fmt,... ) ;    // printf style
// close_trace() ;
//

#ifdef TRACE
 #define open_trace  OpenTraceLog
 #define trace   TraceFun
 #define close_trace  CloseTraceLog
#else
 #define open_trace  1 ? 0 : OpenTraceLog
 #define trace   1 ? 0 : TraceFun
 #define close_trace  1 ? 0 : CloseTraceLog
#endif

int OpenTraceLog( const char *logName ) ;
int TraceFun( char *s, ... ) ;
int CloseTraceLog( ) ;


======= trace.c =======


#include "PmPalmOSNVFS.h"

// Set to true on T5/T650 (helps in case of a crash) or simply discard
Boolean g_bNVFS = false ;

#include <va_list.h>
#define va_start(ap, parm) ap = __va_start(parm)
#define va_end(ap)   ((void)0)
#define va_copy(dest, src) dest = src
#define __va_start(parm) (__std(va_list)) ((char *)&parm + (sizeof(parm) +
(1U) & ~(1U)))
#define va_arg(ap, type) (*(((type *) (ap += sizeof(type))) - 1))

static FileHand  g_fpTrace = NULL ;
static DmOpenRef g_dbRef ;

int OpenTraceLog( const char *logName )
{
 char buf[256] ;

 if( g_fpTrace == NULL )
 {
  Err err ;
  Int32 len = sizeof(DmOpenRef) ;
  g_fpTrace = FileOpen( 0, logName, sysFileTFileStream,
   0,   // creator of the current application
   fileModeReadWrite,
   NULL ) ; // ignore errors

  if( g_fpTrace == NULL )
   return 0 ;

  err = FileControl( fileOpGetOpenDbRef, g_fpTrace, &g_dbRef, &len) ;
  if( err != 0 )
  {
   FileClose( g_fpTrace ) ;
   g_fpTrace = NULL ;
  }

  // Write log header
  {
   UInt32 date = TimGetSeconds() ;
   DateTimeToString( date, buf, true, true ) ;
   StrCat( buf, "\n\n" ) ;
   FileWrite( g_fpTrace, buf, StrLen(buf), 1, NULL) ;
  }
 }
 return 0 ;
}

int CloseTraceLog( )
{
 if( g_fpTrace != NULL )
 {
  FileClose( g_fpTrace ) ;
  g_fpTrace = NULL ;
  g_dbRef = NULL ;
 }
 return 0 ;
}

int TraceFun( char* fmt, ... )
{
 if( g_fpTrace != NULL )
 {
  char buf[256] ;
  va_list args ;
  va_start( args, fmt ) ;
  StrVPrintF( buf, fmt, args ) ;
  va_end( args ) ;

  if( FileWrite( g_fpTrace, buf, StrLen(buf), 1, NULL) == 1 )
  {
   if( g_bNVFS )
    DmSyncDatabase( g_dbRef ) ;
  }
 }
 return 0 ;
}



----- Original Message ----- 
From: "Eythor" <[EMAIL PROTECTED]>
Newsgroups: palm-dev-forum
To: "Palm Developer Forum" <[email protected]>
Sent: Thursday, March 03, 2005 11:16 PM
Subject: Trace statements from device


> Is it possible to view trace statements (a la Palm Reporter) from
execution
> on a device instead of just the sim/emul.?   Is the Palm Debugger the only
> available route or is there a workaround for the HostTraceOutput calls on
a
> device?
>
> Thanks,
> Eythor
>
>
>
> -- 
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/

Reply via email to