• 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: Current Selector
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Current Selector


  • Subject: Re: Current Selector
  • From: Jake Repp <email@hidden>
  • Date: Tue, 7 Jan 2003 11:57:58 -0800

I have the following macros in my current cocoa project:

#define DBG(fmt) printf("[x]: %s:%d: %s: " fmt "\n", (uint)[NSThread currentThread] , __FILE__, __LINE__, __PRETTY_FUNCTION__ );
#define DBG1(fmt, a1) printf("[x]: %s:%d: %s: " fmt "\n", (uint)[NSThread currentThread] , __FILE__ , __LINE__, __PRETTY_FUNCTION__, a1);
#define DBG2(fmt, a1,a2) printf("[x]: %s:%d: %s: " fmt "\n", (uint)[NSThread currentThread] , __FILE__ , __LINE__,__PRETTY_FUNCTION__, a1,a2);
#define DBG3(fmt, a1,a2,a3) printf("[x]: %s:%d: %s: " fmt "\n", (uint)[NSThread currentThread] , __FILE__ , __LINE__, __PRETTY_FUNCTION__, a1,a2,a3);
#define DBG4(fmt, a1,a2,a3,a4) printf("[x]: %s:%d: %s: " fmt "\n", (uint)[NSThread currentThread] , __FILE__ , __LINE__, __PRETTY_FUNCTION__, a1,a2,a3,a4);
#define DBG5(fmt, a1,a2,a3,a4,a5) printf("[x]: %s:%d: %s: " fmt "\n", (uint)[NSThread currentThread] , __FILE__ , __LINE__, __PRETTY_FUNCTION__, a1,a2,a3,a4,a5);
#define DBG6(fmt, a1,a2,a3,a4,a5,a6) printf("[x]: %s:%d: %s: " fmt "\n", (uint)[NSThread currentThread] , __FILE__ , __LINE__, __PRETTY_FUNCTION__, a1,a2,a3,a4,a5,a6);
#define DBG7(fmt, a1,a2,a3,a4,a5,a6,a7) printf("[x]: %s:%d: %s: " fmt "\n", (uint)[NSThread currentThread] , __FILE__ , __LINE__, __PRETTY_FUNCTION__, a1,a2,a3,a4,a5,a6,a7);

These can be conditionally compiled out as they add quite a bit of overhead to the application.

You can also use your cook debug function,
ie:

void _debugoutput(const char *fmt, ...)
{
va_list ap;
va_start(ap,fmt);

if(consoleDebug) vfprintf(stderr, fmt, ap);

if(fileDebug) vfprintf(fileHandle, fmt, ap);

if(networkDebug) writeToDebugSocket(fmt, ap);

va_end(ap);
}

This is all very basic. There are many variations on this theme and extensions to this idea and a number of open source implementations which robust APIs to support logging.

-jake

On Monday, January 6, 2003, at 02:35 PM, Ted Lowery wrote:

Is there a way, programmatically, to get the name of the current selector (method) that is executing? I'm trying to log some debugging info, and I'd like to be able to indicate the selector without having to write a custom like of code for each method.

Cheers, Ted
_______________________________________________
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.
_______________________________________________
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.

  • Follow-Ups:
    • Re: Current Selector
      • From: Jens Bauer <email@hidden>
References: 
 >Current Selector (From: Ted Lowery <email@hidden>)

  • Prev by Date: Re: Quickly drawing non-antialiased, discrete, pixels
  • Next by Date: Re: Working with 32-bit Unicode (NSString stringWithUTF32String: (const UTF32Char *) bytes needed)
  • Previous by thread: Re: Current Selector
  • Next by thread: Re: Current Selector
  • Index(es):
    • Date
    • Thread