Right now, the debug functions only write to a log file when running
in POSE. That works just fine as long as you work locally, but if you
need info from some user it is not that easy to tell a user to run
the viewer in POSE and send you the log file ;-)
To make it easier to get debug info on the device I have added two
new macros, LOG( s ) and LOG_IF( expr, s ) that will write s to a
memo. You can use the _() function to get a printf effect (just as
with MSG and FATAL), e.g. LOG( _( "Allocated %d bytes\n", bytes ) );
The memo function Chris wrote for adding URLs to a memo was used as
a base for this debug function. Actually, I moved the core of the
function to util.c and called it WriteMemoEntry.
void WriteMemoEntry( UInt16* index, UInt32* offset, Char* fmt, ... );
The index should be set to dmMaxRecordIndex the first time you call
this function (will create the record) -- it will contain the new
record index on return. The offset indicates the position in the
record (should be 0 the first time and will be updated by the function
everytime it writes to the memo). The format string (and ...) works
similar to printf.
Example of usage (the WriteMemo function in externalform.c),
/* Write the text from a TextField to a Memo */
void WriteMemo
(
FieldType* field /* field to get text from */
)
{
static UInt16 index = dmMaxRecordIndex;
static UInt32 offset = 0;
static UInt32 secs = 0;
UInt16 length;
length = FldGetTextLength( field );
if ( length == 0 )
return;
/* add header at first invocation */
if ( secs == 0 ) {
DateTimeType dateTime;
secs = TimGetSeconds();
TimSecondsToDateTime( secs, &dateTime );
WriteMemoEntry( &index, &offset, "%s %4d-%02d-%02d %02d:%02d\n",
"Plucker URLs", dateTime.year, dateTime.month, dateTime.day,
dateTime.hour, dateTime.minute );
}
WriteMemoEntry( &index, &offset, "%s\n", FldGetTextPtr( field ) );
}
Still, unless you want to create your own functions that write to a
memo, you don't really have to worry about these details. Either you
use WriteMemo( field ) to write URLs to a memo, or LOG( s ) to write
debug info to a memo.
The macros will only be included if DEBUG and MEMO_LOG are defined
when the viewer is built (the POSE macros will only be included if
DEBUG and POSE_LOG are defined). You can change this manually in
the Makefile, specify it on the command line when running make or
you can enable the settings by using enable-memo-debug and/or
--enable-pose-debug when running configure.
I also added an option to set the version when running configure,
--with-version=VERSION, and some output about the viewer options.
The Makefile in the viewer dir has been split into two moving the
ZLib specific part to the ZLib dir.
/Mike