Skip to content

Commit b0a6afe

Browse files
committed
fix bug: check log level should be printed before call log_write
1 parent 640c922 commit b0a6afe

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

samples/Mac/Component/LogHelper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
+ (void)logWithLevel:(TLogLevel)logLevel moduleName:(const char*)moduleName fileName:(const char*)fileName lineNumber:(int)lineNumber funcName:(const char*)funcName message:(NSString *)message;
2828
+ (void)logWithLevel:(TLogLevel)logLevel moduleName:(const char*)moduleName fileName:(const char*)fileName lineNumber:(int)lineNumber funcName:(const char*)funcName format:(NSString *)format, ...;
2929

30-
+ (BOOL)shouldLog:(int)level;
30+
+ (BOOL)shouldLog:(TLogLevel)level;
3131

3232
@end
3333

samples/Mac/Component/LogHelper.mm

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,13 @@ + (void)logWithLevel:(TLogLevel)logLevel moduleName:(const char*)moduleName file
5050
}
5151
}
5252

53-
+ (BOOL)shouldLog:(int)level {
54-
return YES;
53+
+ (BOOL)shouldLog:(TLogLevel)level {
54+
55+
if (level >= xlogger_Level()) {
56+
return YES;
57+
}
58+
59+
return NO;
5560
}
5661

5762
@end

samples/iOS/iOSDemo/Component/LogHelper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
+ (void)logWithLevel:(TLogLevel)logLevel moduleName:(const char*)moduleName fileName:(const char*)fileName lineNumber:(int)lineNumber funcName:(const char*)funcName message:(NSString *)message;
2828
+ (void)logWithLevel:(TLogLevel)logLevel moduleName:(const char*)moduleName fileName:(const char*)fileName lineNumber:(int)lineNumber funcName:(const char*)funcName format:(NSString *)format, ...;
2929

30-
+ (BOOL)shouldLog:(int)level;
30+
+ (BOOL)shouldLog:(TLogLevel)level;
3131

3232
@end
3333

samples/iOS/iOSDemo/Component/LogHelper.mm

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,13 @@ + (void)logWithLevel:(TLogLevel)logLevel moduleName:(const char*)moduleName file
5050
}
5151
}
5252

53-
+ (BOOL)shouldLog:(int)level {
54-
return YES;
53+
+ (BOOL)shouldLog:(TLogLevel)level {
54+
55+
if (level >= xlogger_Level()) {
56+
return YES;
57+
}
58+
59+
return NO;
5560
}
5661

5762
@end

0 commit comments

Comments
 (0)