BBASMsConsoleLogDef.h
5.13 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//
// BBASMsConsoleLogDef.h
// SWAN
//
// Created by baidu on 2018/10/26.
// Copyright © 2018 baidu. All rights reserved.
//
#ifndef BBASMsConsoleLogDef_h
#define BBASMsConsoleLogDef_h
#ifdef __cplusplus
extern "C" {
#endif
typedef NS_ENUM(NSUInteger, BBASMConsoleLogLevel) {
/// v 详细(表示所有可能的日志,默认级别)
BBASMConsoleLogLevelVerbose = 1,
/// d 调试(表示所有合理的调试用日志)
BBASMConsoleLogLevelInfo = 2,
/// d 调试(表示所有合理的调试用日志)
BBASMConsoleLogLevelDebug = 3,
/// w 警告(表示可能有问题,还没发生错误)
BBASMConsoleLogLevelWarning= 4 ,
/// e 错误(表示有问题并导致出错)
BBASMConsoleLogLevelError = 5
};
typedef NS_ENUM(NSInteger, BBASMInfoLogActionType)
{
BBASMInfoLogCreate = 1,
BBASMInfoLogBack = 2,
BBASMInfoLogForward = 3,
BBASMInfoLogOther = 4,
};
typedef NS_ENUM(NSInteger, BBASMLogLevel)
{
BBASMLogLevelInfo, //info日志 (表示正常使用时的日志)
BBASMLogLevelWarning, //Warning日志 (表示需要强调,或可能有问题,还没发生错误)
BBASMLogLevelError // Error日志 (表示有问题并导致出错)
};
//
__used extern void BBAAddConsoleLog(BBASMConsoleLogLevel type,
NSString *module,
const char *filename,
int lineNumber,
NSString *content,
NSString *appID);
__used extern void BBAAddInfoLog(NSString *module,
NSInteger actionType,
NSString *action,
NSString *from,
NSString *to,
NSString *content,
NSString *appID);
/**
* @brief yalog日志系统
*
* @param appID xcxid
* @param level 日志等级
* @param module 模块名字或者类名
* @param msg 错误信息
* @param filename 类名
* @param lineNumber 行号
*/
__used extern void BBASMLogToFile(NSString *appID,
BBASMLogLevel level,
NSString *module,
NSString *msg,
const char *filename,
int lineNumber);
/*************** 普通日志系统调用宏 同时写入sConsole和日志系统 ***************/
// level:日志级别,content:日志信息,module:模块名字(传空为默认类名),appid:xcxid
#define BBASM_INFO_LOG(level, content, module, appID) \
({if (level == BBASMLogLevelInfo) {BBAAddInfoLog(module, BBASMConsoleLogLevelInfo, nil, nil, nil, content, appID);}\
else if (level == BBASMLogLevelWarning) {BBAAddInfoLog(module, BBASMConsoleLogLevelWarning, nil, nil, nil, content, appID);}\
else {BBAAddInfoLog(module, BBASMConsoleLogLevelError, nil, nil, nil, content, appID);}\
BBASMLogToFile(appID, level, module, content, __FILENAME__, __LINE__);\
})
/*************** 端能力日志系统调用宏,同时写入sConsole和日志系统 ***************/
// level:日志级别,content:日志信息,module:模块名字(传空为默认类名),action 具体的调用,appid:xcxid
#define BBASM_INFO_LOG_ACTION(level, content, module, action, appID) \
({if (level == BBASMLogLevelInfo) {BBAAddInfoLog(module, BBASMConsoleLogLevelInfo, action, nil, nil, content, appID);}\
else if (level == BBASMLogLevelWarning) {BBAAddInfoLog(module, BBASMConsoleLogLevelWarning, action, nil, nil, content, appID);}\
else {BBAAddInfoLog(module, BBASMConsoleLogLevelError, action, nil, nil, content, appID);}\
BBASMLogToFile(appID, level, module, [NSString stringWithFormat:@"%@, %@", action, content], __FILENAME__, __LINE__);\
})
/*************** 私有日志系统调用宏,只写入日志系统 ***************/
// level:日志级别,content:日志信息,module:模块名字(传空为默认类名),appid:xcxid
#define BBASM_Log_To_File(level, content, module, appID) BBASMLogToFile(appID, level, module, content, __FILENAME__, __LINE__)
/*************** sConsole日志 ***************/
/// verbose日志 (表示所有可能的日志,默认级别) 双端对齐
#define BBASM_VERBOSE_LOG(content, module, appID) \
({ \
BBAAddConsoleLog(1, module, __FILE__, __LINE__, content, appID); \
})
/// debug日志 (表示所有合理的调试用日志)双端对齐
#define BBASM_DEBUG_LOG(content, module, appID) \
({ \
BBAAddConsoleLog(3, module, __FILE__, __LINE__, content, appID); \
})
/*************** 日志系统相关 ***************/
/// 获取类名
#define __FILENAME__ (strrchr(__FILE__,'/')+1)
#ifdef __cplusplus
}
#endif
/// 通用的log id key
extern NSString *const BBASMLogCommonServiceID;
/// xcx jsVer key
extern NSString *const BBASMLogServiceInfoJsVer;
/// xcx extentionVer
extern NSString *const BBASMLogServiceInfoExtentionVer;
/// xcx appVer
extern NSString *const BBASMLogServiceInfoAppPkgVer;
#endif /* BBASMsConsoleLogDef_h */