-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCTKConcurrency_Prefix.pch
42 lines (29 loc) · 1.38 KB
/
CTKConcurrency_Prefix.pch
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
//
// Prefix header for all source files of the 'CTKConcurrency' target in the 'CTKConcurrency' project.
//
#ifdef __OBJC__
#import <Foundation/Foundation.h>
//#import <Cocoa/Cocoa.h>
#endif
static NSInteger CTKCurrentThreadNumber()
{
NSString *threadString = [NSString stringWithFormat:@"%@", [NSThread currentThread]];
NSRange numRange = [threadString rangeOfString:@"num = "];
NSUInteger numLength = [threadString length] - numRange.location - numRange.length;
numRange.location = numRange.location + numRange.length;
numRange.length = numLength - 1;
threadString = [threadString substringWithRange:numRange];
return [threadString integerValue];
}
#ifdef DEBUG
# define CTKLog(fmt, ...) NSLog((@"[# %U] %s (%d) " fmt), CTKCurrentThreadNumber(), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
# define CTKLog(fmt, ...)
#endif
#ifdef DEBUG
# define CTKConditionalLog(condition, fmt, ...) if(condition) NSLog((@"[# %U] %s (%d) " fmt), CTKCurrentThreadNumber(), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
# define CTKConditionalLog(condition, fmt, ...)
#endif
#define CTKWarningLog(fmt, ...) NSLog((@"<Warning>: [# %U] %s (%d) " fmt), CTKCurrentThreadNumber(), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#define CTKErrorLog(fmt, ...) NSLog((@"<Error>: [# %U] %s (%d) " fmt), CTKCurrentThreadNumber(), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);