Map Doc  1.0
iOS-引擎SDK-开放平台
MBLogSystem.h
浏览该文件的文档.
1 //
2 // MBLogSystem.h
3 // iNaviCore
4 //
5 // Created by renzc on 2017/12/27.
6 // Copyright © 2017年 Mapbar. All rights reserved.
7 //
8 
9 #import <Foundation/Foundation.h>
10 
11 #define LOG_MACRO(frmt, ...) \
12 [MBLogSystem log: (frmt), ## __VA_ARGS__]
13 
14 #ifdef SDK_DEBUG
15 # define MBLogDebug(frmt, ...) do{ LOG_MACRO((frmt), ##__VA_ARGS__);} while(0)
16 #else
17 # define MBLogDebug(frmt, ...) {}
18 #endif
19 
20 #define MBLog(frmt, ...) do{ LOG_MACRO((frmt), ##__VA_ARGS__); } while(0)
21 
22 typedef NS_ENUM(NSInteger, MB_LOG_LEVEL) {
29 };
30 
31 @class MBLog_T;
32 typedef MBLog_T *mb_log_t;
33 
34 //C接口定义
35 /* Demo:
36  NSArray *filter = @[@"other"];
37  mb_log_filter(filter);
38  mb_log_permitted_level(MB_LOG_LEVEL_WARNING);
39 
40  mb_log_t engineLog = mb_log_create(@"engine", YES, YES);
41  mb_log_info(engineLog, @"engine start %@", self);
42  mb_log_debug(engineLog, @"engine start %@", self);
43  mb_log_warning(engineLog, @"engine start %@", self);
44  mb_log(engineLog, @"engine start %@", self);
45  mb_log_error(engineLog, @"engine start %@", self);
46 
47  mb_log_t otherLog = mb_log_create(@"other", YES, YES);
48  mb_log_info(otherLog, @"other start %@", self);
49  mb_log_debug(otherLog, @"other start %@", self);
50  mb_log_warning(otherLog, @"other start %@", self);
51  mb_log_error(otherLog, @"other start %@", self);
52  mb_log(otherLog, @"other start %@", self);
53 
54  MBLogDebug(@"%@", mb_log_all());
55  */
56 
57 mb_log_t mb_log_create(NSString *tag, BOOL write, BOOL display);
58 
59 void mb_log(mb_log_t log, NSString *des, ...);
60 void mb_log_info(mb_log_t log, NSString *des, ...);
61 void mb_log_debug(mb_log_t log, NSString *des, ...);
62 void mb_log_warning(mb_log_t log, NSString *des, ...);
63 void mb_log_error(mb_log_t log, NSString *des, ...);
64 
65 //控制输出
67 void mb_log_filter(NSArray *fArray);
68 NSArray *mb_log_all();
69 
70 @interface MBLogSystem : NSObject
71 + (instancetype)sharedLogSystem;
72 + (void)log:(NSString *)msg, ...;
73 
74 + (void)setLogPermittedLevel:(MB_LOG_LEVEL)level;
75 + (void)setLogFilterArray:(NSArray *)fArray;
76 + (NSArray *)getLogFilterArray;
77 
78 + (void)logMessage:(NSString *)msg withLog:(mb_log_t)log;
79 + (void)infoMessage:(NSString *)msg withLog:(mb_log_t)log;
80 + (void)debugMessage:(NSString *)msg withLog:(mb_log_t)log;
81 + (void)warningMessage:(NSString *)msg withLog:(mb_log_t)log;
82 + (void)errorMessage:(NSString *)msg withLog:(mb_log_t)log;
83 @end
84 
85 @interface MBLog_T : NSObject
86 @property (nonatomic) NSString *tag;
87 @property (nonatomic, setter=enableWrite:) BOOL write;
88 @property (nonatomic, setter=enableDisplay:) BOOL display;
89 @end
void mb_log_info(mb_log_t log, NSString *des,...)
MB_LOG_LEVEL
Definition: MBLogSystem.h:22
NSString * tag
Definition: MBLogSystem.h:86
Definition: MBLogSystem.h:28
void mb_log_error(mb_log_t log, NSString *des,...)
void mb_log_warning(mb_log_t log, NSString *des,...)
Definition: MBLogSystem.h:26
instancetype sharedLogSystem()
BOOL display
Definition: MBLogSystem.h:88
Definition: MBLogSystem.h:23
Definition: MBLogSystem.h:25
void mb_log_filter(NSArray *fArray)
void mb_log_permitted_level(MB_LOG_LEVEL level)
Definition: MBLogSystem.h:27
BOOL write
Definition: MBLogSystem.h:87
void mb_log_debug(mb_log_t log, NSString *des,...)
mb_log_t mb_log_create(NSString *tag, BOOL write, BOOL display)
NSArray * mb_log_all()
void mb_log(mb_log_t log, NSString *des,...)
NSArray * getLogFilterArray()
MBLog_T * mb_log_t
Definition: MBLogSystem.h:31
Definition: MBLogSystem.h:70
Definition: MBLogSystem.h:24
Definition: MBLogSystem.h:85