MYLog.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #import <CocoaLumberjack/CocoaLumberjack.h>
  2. // We want to use the following log levels:
  3. //
  4. // Fatal
  5. // Error
  6. // Warn
  7. // Notice
  8. // Info
  9. // Debug
  10. //
  11. // All we have to do is undefine the default values,
  12. // and then simply define our own however we want.
  13. // First undefine the default stuff we don't want to use.
  14. #undef DDLogError
  15. #undef DDLogWarn
  16. #undef DDLogInfo
  17. #undef DDLogDebug
  18. #undef DDLogVerbose
  19. // Now define everything how we want it
  20. #define LOG_FLAG_FATAL (1 << 0) // 0...000001
  21. #define LOG_FLAG_ERROR (1 << 1) // 0...000010
  22. #define LOG_FLAG_WARN (1 << 2) // 0...000100
  23. #define LOG_FLAG_NOTICE (1 << 3) // 0...001000
  24. #define LOG_FLAG_INFO (1 << 4) // 0...010000
  25. #define LOG_FLAG_DEBUG (1 << 5) // 0...100000
  26. #define LOG_LEVEL_FATAL (LOG_FLAG_FATAL) // 0...000001
  27. #define LOG_LEVEL_ERROR (LOG_FLAG_ERROR | LOG_LEVEL_FATAL ) // 0...000011
  28. #define LOG_LEVEL_WARN (LOG_FLAG_WARN | LOG_LEVEL_ERROR ) // 0...000111
  29. #define LOG_LEVEL_NOTICE (LOG_FLAG_NOTICE | LOG_LEVEL_WARN ) // 0...001111
  30. #define LOG_LEVEL_INFO (LOG_FLAG_INFO | LOG_LEVEL_NOTICE) // 0...011111
  31. #define LOG_LEVEL_DEBUG (LOG_FLAG_DEBUG | LOG_LEVEL_INFO ) // 0...111111
  32. #define DDLogFatal(frmt, ...) LOG_MAYBE(NO, ddLogLevel, LOG_FLAG_FATAL, 0, nil, __PRETTY_FUNCTION__, frmt, ##__VA_ARGS__)
  33. #define DDLogError(frmt, ...) LOG_MAYBE(NO, ddLogLevel, LOG_FLAG_ERROR, 0, nil, __PRETTY_FUNCTION__, frmt, ##__VA_ARGS__)
  34. #define DDLogWarn(frmt, ...) LOG_MAYBE(YES, ddLogLevel, LOG_FLAG_WARN, 0, nil, __PRETTY_FUNCTION__, frmt, ##__VA_ARGS__)
  35. #define DDLogNotice(frmt, ...) LOG_MAYBE(YES, ddLogLevel, LOG_FLAG_NOTICE, 0, nil, __PRETTY_FUNCTION__, frmt, ##__VA_ARGS__)
  36. #define DDLogInfo(frmt, ...) LOG_MAYBE(YES, ddLogLevel, LOG_FLAG_INFO, 0, nil, __PRETTY_FUNCTION__, frmt, ##__VA_ARGS__)
  37. #define DDLogDebug(frmt, ...) LOG_MAYBE(YES, ddLogLevel, LOG_FLAG_DEBUG, 0, nil, __PRETTY_FUNCTION__, frmt, ##__VA_ARGS__)