-
Notifications
You must be signed in to change notification settings - Fork 10
/
DebugLog.m
30 lines (26 loc) · 910 Bytes
/
DebugLog.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
* 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) %s",threadName,funcName,[fileName UTF8String],lineNumber,[body UTF8String]);
} else {
fprintf(stderr,"%p/%s (%s:%d) %s",[NSThread currentThread],funcName,[fileName UTF8String],lineNumber,[body UTF8String]);
}
[body release];
}