MYLog.h 2.0 KB

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