HBLog.h 846 B

1234567891011121314151617181920
  1. #include <CoreFoundation/CFLogUtilities.h>
  2. #ifdef __DEBUG__
  3. #define HB_LOG_FORMAT(color) CFSTR("\e[1;3" #color "m[%s] \e[m\e[0;3" #color "m%s:%d\e[m \e[0;30;4" #color "m%s:\e[m %@")
  4. #else
  5. #define HB_LOG_FORMAT(color) CFSTR("[%s: %s:%d] %s: %@")
  6. #endif
  7. #define HB_LOG_INTERNAL(color, level, type, ...) CFLog(level, HB_LOG_FORMAT(color), THEOS_INSTANCE_NAME, __BASE_FILE__, __LINE__, type, (__bridge CFStringRef)[NSString stringWithFormat:__VA_ARGS__]);
  8. #ifdef __DEBUG__
  9. #define HBLogDebug(...) HB_LOG_INTERNAL(6, kCFLogLevelNotice, "DEBUG", __VA_ARGS__)
  10. #else
  11. #define HBLogDebug(...)
  12. #endif
  13. #define HBLogInfo(...) HB_LOG_INTERNAL(2, kCFLogLevelNotice, "INFO", __VA_ARGS__)
  14. #define HBLogWarn(...) HB_LOG_INTERNAL(3, kCFLogLevelWarning, "WARN", __VA_ARGS__)
  15. #define HBLogError(...) HB_LOG_INTERNAL(1, kCFLogLevelError, "ERROR", __VA_ARGS__)