Skip to content

Commit b3d1997

Browse files
ccharlesrenoldcodefarmer
authored andcommitted
添加日志分级
Change-Id: Ifbd1ca2e25147eca1d7ed898029029cfa038056d
1 parent da8786b commit b3d1997

File tree

3 files changed

+65
-8
lines changed

3 files changed

+65
-8
lines changed

Source/LinkApp/Classes/AppConfig/AppUIConfig/TIoTExportPrintLogManager.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ NS_ASSUME_NONNULL_BEGIN
1919
*/
2020
- (void)startRecordPrintLog;
2121

22-
- (void)exportLogFileInViewController:(UIViewController *)viewController;
23-
2422
/**
2523
通过系统的分享功能导出Log日志文件
2624
*/

Source/LinkApp/Supporting Files/TIoTLinkKit.pch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@
99
// Include any system framework and library headers here that should be included in all compilation units.
1010
// You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.
1111

12+
//TIoTLOG_LEVEL_NONE,
13+
//TIoTLOG_LEVEL_FATAL,
14+
//TIoTLOG_LEVEL_ERROR,
15+
//TIoTLOG_LEVEL_WARN,
16+
//TIoTLOG_LEVEL_INFO,
17+
//TIoTLOG_LEVEL_DEBUG,
18+
//TIoTLOG_LEVEL_ALL
19+
#ifdef DEBUG
20+
#define TIoTLOG_LEVEL_ALL
21+
#else
22+
#define TIoTLOG_LEVEL_ERROR
23+
#endif
24+
1225
#ifdef __OBJC__
1326

1427
#import "TIoTUIProxy.h"

Source/SDK/LinkCore/QCDeviceCenter/Other/TIoTCoreWMacros.h

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,60 @@
77
#ifndef WCMacros_h
88
#define WCMacros_h
99

10+
typedef NS_ENUM(NSInteger,TIoTLogLevel) {
11+
TIoTLogLevelNone = 0, // 不打印日志信息
12+
TIoTLogLevelFatal = 1 << 0, // 每个严重的错误事件将会导致应用程序的退出。
13+
TIoTLogLevelError = 1 << 1, // 指出虽然发生错误事件,但仍然不影响系统的继续运行。
14+
TIoTLogLevelWarn = 1 << 2, // 会出现潜在错误的情形。
15+
TIoTLogLevelInfo = 1 << 3, // 消息在粗粒度级别上突出强调应用程序的运行过程。
16+
TIoTLogLevelDebug = 1 << 4, // 细粒度信息事件对调试应用程序是非常有帮助的。
17+
TIoTLogLevelAll = 1 << 5, // 不分级别全部打印日志信息
18+
};
19+
20+
/**
21+
*需要在pch文件中配置
22+
*/
23+
//#ifdef DEBUG
24+
//#define TIoTLOG_LEVEL_ALL
25+
//#else
26+
//#define TIoTLOG_LEVEL_ALL
27+
//#endif
28+
29+
#ifdef TIoTLOG_LEVEL_NONE
30+
static const int TIoTLOG_LEVEL = (TIoTLogLevelNone);
31+
#elif defined(TIoTLOG_LEVEL_FATAL)
32+
static const int TIoTLOG_LEVEL = (TIoTLogLevelFatal);
33+
#elif defined(TIoTLOG_LEVEL_ERROR)
34+
static const int TIoTLOG_LEVEL = (TIoTLogLevelFatal | TIoTLogLevelError);
35+
#elif defined(TIoTLOG_LEVEL_WARN)
36+
static const int TIoTLOG_LEVEL = (TIoTLogLevelFatal | TIoTLogLevelError | TIoTLogLevelWarn);
37+
#elif defined(TIoTLOG_LEVEL_INFO)
38+
static const int TIoTLOG_LEVEL = (TIoTLogLevelFatal | TIoTLogLevelError | TIoTLogLevelWarn | TIoTLogLevelInfo);
39+
#elif defined(TIoTLOG_LEVEL_DEBUG)
40+
static const int TIoTLOG_LEVEL = (TIoTLogLevelFatal | TIoTLogLevelError | TIoTLogLevelWarn | TIoTLogLevelInfo | TIoTLogLevelDebug);
41+
#elif defined(TIoTLOG_LEVEL_ALL)
42+
static const int TIoTLOG_LEVEL = (TIoTLogLevelFatal | TIoTLogLevelError | TIoTLogLevelWarn | TIoTLogLevelInfo | TIoTLogLevelDebug);
43+
#endif
44+
45+
#define TIoTLogFatal(fmt, ...) \
46+
if (TIoTLOG_LEVEL & TIoTLogLevelFatal){TIoTLog(fmt, ##__VA_ARGS__);}
47+
48+
#define TIoTLogError(fmt, ...) \
49+
if (TIoTLOG_LEVEL & TIoTLogLevelError){TIoTLog(fmt, ##__VA_ARGS__);}
50+
51+
#define TIoTLogWarn(fmt, ...) \
52+
if (TIoTLOG_LEVEL & TIoTLogLevelWarn){TIoTLog(fmt, ##__VA_ARGS__);}
53+
54+
#define TIoTLogInfo(fmt, ...) \
55+
if (TIoTLOG_LEVEL & TIoTLogLevelInfo){TIoTLog(fmt, ##__VA_ARGS__);}
56+
57+
#define TIoTLogDebug(fmt, ...) \
58+
if (TIoTLOG_LEVEL & TIoTLogLevelDebug){TIoTLog(fmt, ##__VA_ARGS__);}
59+
1060
#define QCLog(fmt, ...) if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"pLogEnable"] boolValue]) {NSLog((@"\n--------------\n" fmt @"\n================================="), ##__VA_ARGS__);}
1161

62+
#define TIoTLog(FORMAT, ...) if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"pLogEnable"] boolValue]) {NSLog(@"[%s]:[%s]:[%s]:[%d]",[[[NSString alloc] initWithData:[[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] dataUsingEncoding:NSUTF8StringEncoding] encoding:NSNonLossyASCIIStringEncoding] UTF8String],[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String],__FUNCTION__,__LINE__);}
63+
1264
#endif /* WCMacros_h */
1365

1466

@@ -18,9 +70,3 @@
1870
#define WCLog(...)
1971
#endif
2072

21-
22-
#ifdef DEBUG
23-
#define TIoTLog(FORMAT, ...) fprintf(stderr,"\n %s:%d %s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String],__LINE__, [[[NSString alloc] initWithData:[[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] dataUsingEncoding:NSUTF8StringEncoding] encoding:NSNonLossyASCIIStringEncoding] UTF8String]);
24-
#else
25-
#define TIoTLog(...)
26-
#endif

0 commit comments

Comments
 (0)