aliyun-oss-react-native

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Software License Agreement (BSD License)
  2. //
  3. // Copyright (c) 2010-2016, 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. // Disable legacy macros
  16. #ifndef OSSDD_LEGACY_MACROS
  17. #define OSSDD_LEGACY_MACROS 0
  18. #endif
  19. #import "OSSDDLog.h"
  20. /**
  21. * The constant/variable/method responsible for controlling the current log level.
  22. **/
  23. #ifndef OSSLOG_LEVEL_DEF
  24. #define OSSLOG_LEVEL_DEF ossLogLevel
  25. #endif
  26. /**
  27. * Whether async should be used by log messages, excluding error messages that are always sent sync.
  28. **/
  29. #ifndef OSSLOG_ASYNC_ENABLED
  30. #define OSSLOG_ASYNC_ENABLED YES
  31. #endif
  32. /**
  33. * These are the two macros that all other macros below compile into.
  34. * These big multiline macros makes all the other macros easier to read.
  35. **/
  36. #define OSSLOG_MACRO(isAsynchronous, lvl, flg, ctx, atag, fnct, frmt, ...) \
  37. [OSSDDLog log : isAsynchronous \
  38. level : lvl \
  39. flag : flg \
  40. context : ctx \
  41. file : __FILE__ \
  42. function : fnct \
  43. line : __LINE__ \
  44. tag : atag \
  45. format : (frmt), ## __VA_ARGS__]
  46. /**
  47. * Define version of the macro that only execute if the log level is above the threshold.
  48. * The compiled versions essentially look like this:
  49. *
  50. * if (logFlagForThisLogMsg & ddLogLevel) { execute log message }
  51. *
  52. * When LOG_LEVEL_DEF is defined as ddLogLevel.
  53. *
  54. * As shown further below, Lumberjack actually uses a bitmask as opposed to primitive log levels.
  55. * This allows for a great amount of flexibility and some pretty advanced fine grained logging techniques.
  56. *
  57. * Note that when compiler optimizations are enabled (as they are for your release builds),
  58. * the log messages above your logging threshold will automatically be compiled out.
  59. *
  60. * (If the compiler sees LOG_LEVEL_DEF/ddLogLevel declared as a constant, the compiler simply checks to see
  61. * if the 'if' statement would execute, and if not it strips it from the binary.)
  62. *
  63. * We also define shorthand versions for asynchronous and synchronous logging.
  64. **/
  65. #define OSSLOG_MAYBE(async, lvl, flg, ctx, tag, fnct, frmt, ...) \
  66. do { if(lvl & flg) OSSLOG_MACRO(async, lvl, flg, ctx, tag, fnct, frmt, ##__VA_ARGS__); } while(0)
  67. /**
  68. * Ready to use log macros with no context or tag.
  69. **/
  70. #define OSSDDLogError(frmt, ...) OSSLOG_MAYBE(NO, OSSLOG_LEVEL_DEF, OSSDDLogFlagError, 0, nil, __PRETTY_FUNCTION__, frmt, ##__VA_ARGS__)
  71. #define OSSDDLogWarn(frmt, ...) OSSLOG_MAYBE(OSSLOG_ASYNC_ENABLED, OSSLOG_LEVEL_DEF, OSSDDLogFlagWarning, 0, nil, __PRETTY_FUNCTION__, frmt, ##__VA_ARGS__)
  72. #define OSSDDLogInfo(frmt, ...) OSSLOG_MAYBE(OSSLOG_ASYNC_ENABLED, OSSLOG_LEVEL_DEF, OSSDDLogFlagInfo, 0, nil, __PRETTY_FUNCTION__, frmt, ##__VA_ARGS__)
  73. #define OSSDDLogDebug(frmt, ...) OSSLOG_MAYBE(OSSLOG_ASYNC_ENABLED, OSSLOG_LEVEL_DEF, OSSDDLogFlagDebug, 0, nil, __PRETTY_FUNCTION__, frmt, ##__VA_ARGS__)
  74. #define OSSDDLogVerbose(frmt, ...) OSSLOG_MAYBE(OSSLOG_ASYNC_ENABLED, OSSLOG_LEVEL_DEF, OSSDDLogFlagVerbose, 0, nil, __PRETTY_FUNCTION__, frmt, ##__VA_ARGS__)