forked from geoloqi/MapAttack-iPhone
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added DLog function for better debug logging.
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,20 @@ | |||
/* | |||
* DebugLog.h | |||
* DebugLog | |||
* | |||
* Created by Karl Kraft on 3/22/09. | |||
* Copyright 2009 Karl Kraft. All rights reserved. | |||
* | |||
*/ | |||
|
|||
#ifdef DEBUG | |||
|
|||
#define DLog(args...) _DebugLog(__FILE__,__LINE__,__PRETTY_FUNCTION__,args); | |||
|
|||
#else | |||
|
|||
#define DLog(x...) | |||
|
|||
#endif | |||
|
|||
void _DebugLog(const char *file, int lineNumber, const char *funcName, NSString *format,...); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,30 @@ | |||
/* | |||
* DebugLog.m | |||
* DebugLog | |||
* | |||
* Created by Karl Kraft on 3/22/09. | |||
* Copyright 2009 Karl Kraft. All rights reserved. | |||
* | |||
*/ | |||
|
|||
#include "DebugLog.h" | |||
|
|||
void _DebugLog(const char *file, int lineNumber, const char *funcName, NSString *format,...) { | |||
va_list ap; | |||
|
|||
va_start (ap, format); | |||
if (![format hasSuffix: @"\n"]) { | |||
format = [format stringByAppendingString: @"\n"]; | |||
} | |||
NSString *body = [[NSString alloc] initWithFormat: format arguments: ap]; | |||
va_end (ap); | |||
const char *threadName = [[[NSThread currentThread] name] UTF8String]; | |||
NSString *fileName=[[NSString stringWithUTF8String:file] lastPathComponent]; | |||
if (threadName) { | |||
fprintf(stderr,"%s/%s (%s:%d) \n\t\t%s",threadName,funcName,[fileName UTF8String],lineNumber,[body UTF8String]); | |||
} else { | |||
fprintf(stderr,"%p/%s (%s:%d) \n\t\t%s",[NSThread currentThread],funcName,[fileName UTF8String],lineNumber,[body UTF8String]); | |||
} | |||
[body release]; | |||
} | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters