25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

76 lines
3.5 KiB

  1. // Software License Agreement (BSD License)
  2. //
  3. // Copyright (c) 2010-2015, Deusty, LLC
  4. // All rights reserved.
  5. //
  6. // Redistribution and use of this software in source and binary forms,
  7. // with or without modification, are permitted provided that the following conditions are met:
  8. //
  9. // * Redistributions of source code must retain the above copyright notice,
  10. // this list of conditions and the following disclaimer.
  11. //
  12. // * Neither the name of Deusty nor the names of its contributors may be used
  13. // to endorse or promote products derived from this software without specific
  14. // prior written permission of Deusty, LLC.
  15. /**
  16. * Legacy macros used for 1.9.x backwards compatibility.
  17. *
  18. * Imported by default when importing a DDLog.h directly and DD_LEGACY_MACROS is not defined and set to 0.
  19. **/
  20. #if DD_LEGACY_MACROS
  21. #warning CocoaLumberjack 1.9.x legacy macros enabled. \
  22. Disable legacy macros by importing CocoaLumberjack.h or DDLogMacros.h instead of DDLog.h or add `#define DD_LEGACY_MACROS 0` before importing DDLog.h.
  23. #ifndef LOG_LEVEL_DEF
  24. #define LOG_LEVEL_DEF ddLogLevel
  25. #endif
  26. #define LOG_FLAG_ERROR DDLogFlagError
  27. #define LOG_FLAG_WARN DDLogFlagWarning
  28. #define LOG_FLAG_INFO DDLogFlagInfo
  29. #define LOG_FLAG_DEBUG DDLogFlagDebug
  30. #define LOG_FLAG_VERBOSE DDLogFlagVerbose
  31. #define LOG_LEVEL_OFF DDLogLevelOff
  32. #define LOG_LEVEL_ERROR DDLogLevelError
  33. #define LOG_LEVEL_WARN DDLogLevelWarning
  34. #define LOG_LEVEL_INFO DDLogLevelInfo
  35. #define LOG_LEVEL_DEBUG DDLogLevelDebug
  36. #define LOG_LEVEL_VERBOSE DDLogLevelVerbose
  37. #define LOG_LEVEL_ALL DDLogLevelAll
  38. #define LOG_ASYNC_ENABLED YES
  39. #define LOG_ASYNC_ERROR ( NO && LOG_ASYNC_ENABLED)
  40. #define LOG_ASYNC_WARN (YES && LOG_ASYNC_ENABLED)
  41. #define LOG_ASYNC_INFO (YES && LOG_ASYNC_ENABLED)
  42. #define LOG_ASYNC_DEBUG (YES && LOG_ASYNC_ENABLED)
  43. #define LOG_ASYNC_VERBOSE (YES && LOG_ASYNC_ENABLED)
  44. #define LOG_MACRO(isAsynchronous, lvl, flg, ctx, atag, fnct, frmt, ...) \
  45. [DDLog log : isAsynchronous \
  46. level : lvl \
  47. flag : flg \
  48. context : ctx \
  49. file : __FILE__ \
  50. function : fnct \
  51. line : __LINE__ \
  52. tag : atag \
  53. format : (frmt), ## __VA_ARGS__]
  54. #define LOG_MAYBE(async, lvl, flg, ctx, fnct, frmt, ...) \
  55. do { if(lvl & flg) LOG_MACRO(async, lvl, flg, ctx, nil, fnct, frmt, ##__VA_ARGS__); } while(0)
  56. #define LOG_OBJC_MAYBE(async, lvl, flg, ctx, frmt, ...) \
  57. LOG_MAYBE(async, lvl, flg, ctx, __PRETTY_FUNCTION__, frmt, ## __VA_ARGS__)
  58. #define DDLogError(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_ERROR, LOG_LEVEL_DEF, LOG_FLAG_ERROR, 0, frmt, ##__VA_ARGS__)
  59. #define DDLogWarn(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_WARN, LOG_LEVEL_DEF, LOG_FLAG_WARN, 0, frmt, ##__VA_ARGS__)
  60. #define DDLogInfo(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_INFO, LOG_LEVEL_DEF, LOG_FLAG_INFO, 0, frmt, ##__VA_ARGS__)
  61. #define DDLogDebug(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_DEBUG, LOG_LEVEL_DEF, LOG_FLAG_DEBUG, 0, frmt, ##__VA_ARGS__)
  62. #define DDLogVerbose(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_VERBOSE, LOG_LEVEL_DEF, LOG_FLAG_VERBOSE, 0, frmt, ##__VA_ARGS__)
  63. #endif