-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrefixHeader.pch
executable file
·57 lines (46 loc) · 1.36 KB
/
PrefixHeader.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Created by ideawu on 2/20/19.
// Copyright © 2019 ideawu. All rights reserved.
//
#ifndef PrefixHeader_h
#define PrefixHeader_h
#ifdef __OBJC__
#import <Foundation/Foundation.h>
inline
static void my_log(NSString *fmt, ...){
NSDateFormatter *f = [[NSDateFormatter alloc] init];
[f setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS"];
NSString *time = [f stringFromDate:[NSDate date]];
va_list args;
va_start(args, fmt);
NSString *msg = [[NSString alloc] initWithFormat:fmt arguments:args];
va_end(args);
printf("%s %s\n", time.UTF8String, msg.UTF8String);
}
#define L_MYLOG(level, fmt, args...) \
my_log((level @" %@(%d): " fmt), [@(__FILE__) lastPathComponent], __LINE__, ##args)
#undef log_trace
#undef log_debug
#undef log_info
#undef log_error
#ifdef DEBUG
# define VERSION VER_NUM "(for development only)"
# define log_trace(...) L_MYLOG(@"[TRACE]", __VA_ARGS__)
# define log_debug(...) L_MYLOG(@"[DEBUG]", __VA_ARGS__)
#else
# define VERSION VER_NUM "(for production)"
# define log_trace(...)
# define log_debug(...)
#endif
#define log_info(...) L_MYLOG(@"[INFO] ", __VA_ARGS__)
#define log_error(...) L_MYLOG(@"[ERROR]", __VA_ARGS__)
#ifdef DEBUG
# define LOG_FIRST_RUN() do{ \
static int i = 0; \
if(i == 0){ \
i = 1; \
log_debug(@"== FIRST_RUN == %s", __func__); \
} \
}while(0)
#endif
#endif // end __OBJC__
#endif /* PrefixHeader_h */