gnu3dkit-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnu3dkit-dev] G3DSphere -wrapPoint: and NSLog usage


From: Brent Gulanowski
Subject: Re: [Gnu3dkit-dev] G3DSphere -wrapPoint: and NSLog usage
Date: Tue, 22 Oct 2002 10:55:46 -0400

On Tuesday, October 22, 2002, at 01:37  AM, Philippe C.D. Robert wrote:

On Monday, October 21, 2002, at 10:38  Uhr, Brent Gulanowski wrote:

This method ends with the following NSLog() call:

    NSLog(@"<%@ %x> distance %f > radius %f - ignoring",dist,_radius);

The first two format specifiers appear to have no associated values. Is this meant to preface the output with the class and pointer value? That would require:

NSLog(@"<%@ %x> distance %f > radius %f - ignoring",self, (void *)self, dist,_radius);

however I wanted to clarify the purpose.

Yes, this should be the case ...sigh You see, the ObjC classes in the GK are rarely used and test cases are not really available...:-(

If you find such issues by writing little test apps, please sed them to me or submit them directly (into the Testing dir)!

So far I'm just reading the code, looking for any discrepancies and studying the algorithms. I am working on some ideas for application-level classes that will take primitive descriptions and generate tessellated meshes, as I"ve previously described. Unfortunately this means I have to catch up on a lot of geometry knowledge I've missed over the years.

I'd also like to bring up the NSLog() usage guidelines, or lack of them. Shall we reserve them for debug, and create a debug flag to wrap around debug code like logging?

For 0.4 I planned to remove NSLog() calls and introduce a special print command which prints warnings, errors and so on depending on a debug level which can be specified via the shell. What do you think?

I like that approach. The standard approach is to use macros, and when not in debug mode define them to nothing.

#ifdef G3D_DEBUG
#if G3D_DEGUG==1
#define debuglog( format, args... ) fprintf( errorFile, format, args )
#elif G3D_DEGUG==2
#define debuglog( format, args... ) fprintf( stderr, format, args )
#endif
#else
#define debuglog( format, args... )

(actually, the above is a bit unwieldy -- probably better to redirect stderr based on debug level and have only on/off macros).

or

#ifdef G3D_DEBUG
   #if G3D_DEGUG==1
      // set stderr to one thing
   #elif G3D_DEBUG==2
      //set stderr to something else
   #endif
#define debuglog( message ) NSLog( "G3D debug: <%@ %s> %s", self, NSStringFromSelector(_cmd), message )
#elif
   #define debuglog( message )
#endif

If we're really fancy we can declare an intermediary string buffer so that we can insert variable arguments in the message with snprintf(). You might in fact want to write a function to replace NSLog in that case.

I recommend a new file for each library which holds the debug macros and functions.

--
Brent Gulanowski                                address@hidden

http://inkubator.idevgames.com/
Working together to make great software.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]