forked from dennisreimann/ioctocat
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJLog.h
97 lines (75 loc) · 2.07 KB
/
JLog.h
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Creator: Patrick Stein aka [email protected]
#ifndef DEBUG
#define DEBUG 0
#endif
#define FIXRANGE(A,MIN,MAX) \
{ \
if( A < MIN ) \
{ \
A = MIN; \
} \
else if( A >MAX ) \
{ \
A = MAX; \
} \
}
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#if MAC_OS_X_VERSION_10_5 && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
#else
#define NSInteger int
#endif
#ifndef JLog
#define JLine(firstarg, ...) ([NSString stringWithFormat:@"\t%s\n%@\n\n==========\n\n",__FUNCTION__,[NSString stringWithFormat:firstarg, ##__VA_ARGS__ ]])
#define JLineC(firstarg, ...) ([NSString stringWithFormat:@"\t(%08x.%04d) %s %s():\n%@\n\n==========\n\n",NULL,__LINE__,__FILE__,__FUNCTION__,[NSString stringWithFormat:firstarg , ##__VA_ARGS__ ]])
#define JLog(firstarg, ...) NSLog(@"%@",JLine(firstarg , ##__VA_ARGS__ ))
#define JLogC(firstarg, ...) NSLog(@"%@",JLineC(firstarg , ##__VA_ARGS__ ))
#define DJLog if(DEBUG)JLog
#define DJLogC if(DEBUG)JLogC
#define D2JLog if(DEBUG>1)JLog
#define D2JLogC if(DEBUG>1)JLogC
#define D3JLog if(DEBUG>2)JLog
#define D3JLogC if(DEBUG>2)JLogC
#define DJLOG if(DEBUG)DJLog(@"");
#define D2JLOG if(DEBUG>1)DJLog(@"");
#define D3JLOG if(DEBUG>1)DJLog(@"");
#endif
#ifndef DNSLog
#define DNSLog if(DEBUG)JLogC
#define D2NSLog if(DEBUG>1)JLogC
#endif
#ifdef DEBUGRETAIN
#define DEBUGRETAINCYCLE \
- retain\
{\
[super retain];\
JLog(@"%d",[self retainCount]);\
return self;\
}\
\
- (void)release\
{\
JLog(@"%d",[self retainCount]-1);\
[super release];\
}\
- autorelease\
{\
[super autorelease];\
JLog(@"%d",[self retainCount]);\
return self;\
}\
#else
#define DEBUGRETAINCYCLE
#endif
#if NDEBUG
#define TIMELOG(nsstring)
#else
#define TIMELOG(nsstring) \
{ \
static CFAbsoluteTime timeloglasttime = 0; \
CFAbsoluteTime timelogtimenow = CFAbsoluteTimeGetCurrent(); \
NSLog(@"%@ %3.2fHz %8.4fms",nsstring,1.0/(timelogtimenow-timeloglasttime),(timelogtimenow-timeloglasttime)*1000.0); \
timeloglasttime = timelogtimenow; \
}
#endif
#endif