• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: When I don't want NSLog() for normal use?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: When I don't want NSLog() for normal use?


  • Subject: Re: When I don't want NSLog() for normal use?
  • From: dan sandler <email@hidden>
  • Date: Wed, 23 Oct 2002 23:25:36 -0700

> I need to declare a global header for kTrace and I feel it's just so
> messy and awkward. Is there an alternative way to do this? How do you
> implement debugging?

I've got a solution I'm pretty happy with, so I'll share. Here's the
relevant part of my usual Debug.h:

#ifdef DEBUG
#define LOG(x) NSLog x
#define DEBUG_ONLY(x) x
#else
#define LOG(x)
#define DEBUG_ONLY(x)
#endif

In my code, after #importing Debug.h, I use the LOG macro for a simple
logging message:

LOG((@"-[MagicGenie rub]: djinn has now been rubbed %d times\n", _rubCount));

[Note the doubled parentheses above -- this is required to sneak the
va_args into NSLog the right way.]

If I need something more-complex [such as a block of setup code to
assemble a call to LOG(())], I use the DEBUG_ONLY macro:

DEBUG_ONLY(
{ ... code that should only be run in debugging mode ... }
)

Finally, I've set up my Development buildStyle to include the following
in the OTHER_CFLAGS build setting:

-DDEBUG

By switching the build style to Deployment, not only is the logging &
debugging code turned off, it's *removed* from the built executable.

Good luck,
-ds
http://dsandler.org/soft/macosx/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >When I don't want NSLog() for normal use? (From: Hisaoki Nishida <email@hidden>)

  • Prev by Date: [OT] Help Viewer blows
  • Next by Date: Re: When I don't want NSLog() for normal use?
  • Previous by thread: When I don't want NSLog() for normal use?
  • Next by thread: Re: When I don't want NSLog() for normal use?
  • Index(es):
    • Date
    • Thread