SDL_log.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*
  2. SDL - Simple DirectMedia Layer
  3. Copyright (C) 1997-2011 Sam Lantinga
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with this library; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15. Sam Lantinga
  16. [email protected]
  17. */
  18. /**
  19. * \file SDL_log.h
  20. *
  21. * Simple log messages with categories and priorities.
  22. *
  23. * By default logs are quiet, but if you're debugging SDL you might want:
  24. *
  25. * SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN);
  26. *
  27. * Here's where the messages go on different platforms:
  28. * Windows: debug output stream
  29. * Android: log output
  30. * Others: standard error output (stderr)
  31. */
  32. #ifndef _SDL_log_h
  33. #define _SDL_log_h
  34. #include "SDL_stdinc.h"
  35. #include "begin_code.h"
  36. /* Set up for C function definitions, even when using C++ */
  37. #ifdef __cplusplus
  38. /* *INDENT-OFF* */
  39. extern "C" {
  40. /* *INDENT-ON* */
  41. #endif
  42. /**
  43. * \brief The maximum size of a log message
  44. *
  45. * Messages longer than the maximum size will be truncated
  46. */
  47. #define SDL_MAX_LOG_MESSAGE 4096
  48. /**
  49. * \brief The predefined log categories
  50. *
  51. * By default the application category is enabled at the INFO level,
  52. * and all other categories are enabled at the CRITICAL level.
  53. */
  54. enum
  55. {
  56. SDL_LOG_CATEGORY_APPLICATION,
  57. SDL_LOG_CATEGORY_ERROR,
  58. SDL_LOG_CATEGORY_SYSTEM,
  59. SDL_LOG_CATEGORY_AUDIO,
  60. SDL_LOG_CATEGORY_VIDEO,
  61. SDL_LOG_CATEGORY_RENDER,
  62. SDL_LOG_CATEGORY_INPUT,
  63. /* Reserved for future SDL library use */
  64. SDL_LOG_CATEGORY_RESERVED1,
  65. SDL_LOG_CATEGORY_RESERVED2,
  66. SDL_LOG_CATEGORY_RESERVED3,
  67. SDL_LOG_CATEGORY_RESERVED4,
  68. SDL_LOG_CATEGORY_RESERVED5,
  69. SDL_LOG_CATEGORY_RESERVED6,
  70. SDL_LOG_CATEGORY_RESERVED7,
  71. SDL_LOG_CATEGORY_RESERVED8,
  72. SDL_LOG_CATEGORY_RESERVED9,
  73. SDL_LOG_CATEGORY_RESERVED10,
  74. /* Beyond this point is reserved for application use, e.g.
  75. enum {
  76. MYAPP_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM,
  77. MYAPP_CATEGORY_AWESOME2,
  78. MYAPP_CATEGORY_AWESOME3,
  79. ...
  80. };
  81. */
  82. SDL_LOG_CATEGORY_CUSTOM
  83. };
  84. /**
  85. * \brief The predefined log priorities
  86. */
  87. typedef enum
  88. {
  89. SDL_LOG_PRIORITY_VERBOSE = 1,
  90. SDL_LOG_PRIORITY_DEBUG,
  91. SDL_LOG_PRIORITY_INFO,
  92. SDL_LOG_PRIORITY_WARN,
  93. SDL_LOG_PRIORITY_ERROR,
  94. SDL_LOG_PRIORITY_CRITICAL,
  95. SDL_NUM_LOG_PRIORITIES
  96. } SDL_LogPriority;
  97. /**
  98. * \brief Set the priority of all log categories
  99. */
  100. extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority);
  101. /**
  102. * \brief Set the priority of a particular log category
  103. */
  104. extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category,
  105. SDL_LogPriority priority);
  106. /**
  107. * \brief Set the priority of a particular log category
  108. */
  109. extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category);
  110. /**
  111. * \brief Reset all priorities to default.
  112. *
  113. * \note This is called in SDL_Quit().
  114. */
  115. extern DECLSPEC void SDLCALL SDL_LogResetPriorities(void);
  116. /**
  117. * \brief Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO
  118. */
  119. extern DECLSPEC void SDLCALL SDL_Log(const char *fmt, ...);
  120. /**
  121. * \brief Log a message with SDL_LOG_PRIORITY_VERBOSE
  122. */
  123. extern DECLSPEC void SDLCALL SDL_LogVerbose(int category, const char *fmt, ...);
  124. /**
  125. * \brief Log a message with SDL_LOG_PRIORITY_INFO
  126. */
  127. extern DECLSPEC void SDLCALL SDL_LogInfo(int category, const char *fmt, ...);
  128. /**
  129. * \brief Log a message with SDL_LOG_PRIORITY_WARN
  130. */
  131. extern DECLSPEC void SDLCALL SDL_LogWarn(int category, const char *fmt, ...);
  132. /**
  133. * \brief Log a message with SDL_LOG_PRIORITY_ERROR
  134. */
  135. extern DECLSPEC void SDLCALL SDL_LogError(int category, const char *fmt, ...);
  136. /**
  137. * \brief Log a message with SDL_LOG_PRIORITY_CRITICAL
  138. */
  139. extern DECLSPEC void SDLCALL SDL_LogCritical(int category, const char *fmt, ...);
  140. /**
  141. * \brief Log a message with the specified category and priority.
  142. */
  143. extern DECLSPEC void SDLCALL SDL_LogMessage(int category,
  144. SDL_LogPriority priority,
  145. const char *fmt, ...);
  146. /**
  147. * \brief Log a message with the specified category and priority.
  148. */
  149. extern DECLSPEC void SDLCALL SDL_LogMessageV(int category,
  150. SDL_LogPriority priority,
  151. const char *fmt, va_list ap);
  152. /**
  153. * \brief The prototype for the log output function
  154. */
  155. typedef void (*SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message);
  156. /**
  157. * \brief Get the current log output function.
  158. */
  159. extern DECLSPEC void SDLCALL SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata);
  160. /**
  161. * \brief This function allows you to replace the default log output
  162. * function with one of your own.
  163. */
  164. extern DECLSPEC void SDLCALL SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata);
  165. /* Ends C function definitions when using C++ */
  166. #ifdef __cplusplus
  167. /* *INDENT-OFF* */
  168. }
  169. /* *INDENT-ON* */
  170. #endif
  171. #include "close_code.h"
  172. #endif /* _SDL_log_h */
  173. /* vi: set ts=4 sw=4 expandtab: */