Нет описания

AlibcLog.h 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * AlibcLog.h
  3. *
  4. * 阿里百川电商
  5. * 项目名称:阿里巴巴电商 AlibcTradeCommon
  6. * 版本号:3.1.1.200
  7. * 发布时间:2017-08-21
  8. * 开发团队:阿里巴巴百川商业化团队
  9. * 阿里巴巴电商SDK答疑群号:1488705339 2071154343(阿里旺旺)
  10. * Copyright (c) 2016-2019 阿里巴巴-移动事业群-百川. All rights reserved.
  11. */
  12. #import <Foundation/Foundation.h>
  13. #ifndef AlibcLog_h
  14. #define AlibcLog_h
  15. #ifdef DEBUG
  16. #define BCAssert(condition, info) \
  17. do { \
  18. @try { \
  19. if (!(condition)) { \
  20. if(tbim_check_debugger() == 0){ \
  21. TLOG_ERROR(info)\
  22. [NSException raise:@"Assert" format:@"%@",info];} \
  23. else {TLOG_ALERT(info)} \
  24. } \
  25. }\
  26. @catch (NSException *exception) {} \
  27. } while (0);
  28. #else
  29. #define BCAssert(condition, info) \
  30. do { \
  31. if (!(condition)) {TLOG_ERROR(info)}\
  32. } while (0);
  33. #endif
  34. #ifdef DEBUG
  35. #define BCAssert_F(condition, frmt, ...) \
  36. do { \
  37. @try { \
  38. if (!(condition)) { \
  39. if(tbim_check_debugger() == 0){ \
  40. TLOG_ERROR_F(frmt,##__VA_ARGS__) \
  41. [NSException raise:@"Assert" format:@"Assert"];} \
  42. else {TLOG_ALERT_F(frmt,##__VA_ARGS__)} \
  43. } \
  44. }\
  45. @catch (NSException *exception) {} \
  46. } while (0);
  47. #else
  48. #define BCAssert_F(condition, frmt, ...) \
  49. do { \
  50. if (!(condition)) { \
  51. TLOG_ERROR_F(frmt,##__VA_ARGS__) \
  52. } \
  53. } while (0);
  54. #endif
  55. #define TLOG_ALERT(info) [[AlibcLog GetInstance] showAssertAlert:__FILE__ funcName:__func__ line: __LINE__ msg:info];
  56. #define TLOG_ALERT_F(fmt, ...) [[AlibcLog GetInstance] showAssertAlert:__FILE__ funcName:__func__ line: __LINE__ msg:[NSString stringWithFormat:fmt, ##__VA_ARGS__]];
  57. #define TLOG_DEBUG_EMPTY [[AlibcLog GetInstance] logDebugMsg:__FILE__ funcName:__func__ line: __LINE__ msg:@""];
  58. #define TLOG_INFO_EMPTY [[AlibcLog GetInstance] logInfoMsg:__FILE__ funcName:__func__ line: __LINE__ msg:@""];
  59. #define TLOG_WARN_EMPTY [[AlibcLog GetInstance] logWarnMsg:__FILE__ funcName:__func__ line: __LINE__ msg:@""];
  60. #define TLOG_ERROR_EMPTY [[AlibcLog GetInstance] logErrorMsg:__FILE__ funcName:__func__ line: __LINE__ msg:@""];
  61. #define TLOG_DEBUG(info) [[AlibcLog GetInstance] logDebugMsg:__FILE__ funcName:__func__ line:__LINE__ msg:info];
  62. #define TLOG_INFO(info) [[AlibcLog GetInstance] logInfoMsg:__FILE__ funcName:__func__ line:__LINE__ msg:info];
  63. #define TLOG_WARN(info) [[AlibcLog GetInstance] logWarnMsg:__FILE__ funcName:__func__ line: __LINE__ msg:info];
  64. #define TLOG_ERROR(info) [[AlibcLog GetInstance] logErrorMsg:__FILE__ funcName:__func__ line: __LINE__ msg:info];
  65. #define TLOG_DEBUG_F(fmt, ...) [[AlibcLog GetInstance] logDebugMsg:__FILE__ funcName:__func__ line: __LINE__ msg:[NSString stringWithFormat:fmt, ##__VA_ARGS__]];
  66. #define TLOG_INFO_F(fmt, ...) [[AlibcLog GetInstance] logInfoMsg:__FILE__ funcName:__func__ line: __LINE__ msg:[NSString stringWithFormat:fmt, ##__VA_ARGS__]];
  67. #define TLOG_WARN_F(fmt, ...) [[AlibcLog GetInstance] logWarnMsg:__FILE__ funcName:__func__ line: __LINE__ msg:[NSString stringWithFormat:fmt, ##__VA_ARGS__]];
  68. #define TLOG_ERROR_F(fmt, ...) [[AlibcLog GetInstance] logErrorMsg:__FILE__ funcName:__func__ line: __LINE__ msg:[NSString stringWithFormat:fmt, ##__VA_ARGS__]];
  69. int tbim_check_debugger();
  70. @interface AlibcLog : NSObject
  71. + (instancetype)GetInstance;
  72. - (NSString *)getLogFilePath;
  73. - (void)showAssertAlert:(const char *)file funcName:(const char *)func line:(int)line msg:(NSString *)msg;
  74. - (void)logDebugMsg:(const char *)file funcName:(const char *)func line:(int)line msg:(NSString *)msg;
  75. - (void)logInfoMsg:(const char *)file funcName:(const char *)func line:(int)line msg:(NSString *)msg;
  76. - (void)logWarnMsg:(const char *)file funcName:(const char *)func line:(int)line msg:(NSString *)msg;
  77. - (void)logErrorMsg:(const char *)file funcName:(const char *)func line:(int)line msg:(NSString *)msg;
  78. - (void)setDebugLogOpen:(BOOL)isDebugLogOpen;
  79. @end
  80. #endif