sdl_log.odin 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package sdl2
  2. import "core:c"
  3. when ODIN_OS == .Windows {
  4. foreign import lib "SDL2.lib"
  5. } else {
  6. foreign import lib "system:SDL2"
  7. }
  8. MAX_LOG_MESSAGE :: 4096
  9. LogCategory :: enum c.int {
  10. APPLICATION,
  11. ERROR,
  12. ASSERT,
  13. SYSTEM,
  14. AUDIO,
  15. VIDEO,
  16. RENDER,
  17. INPUT,
  18. TEST,
  19. /* Reserved for future SDL library use */
  20. RESERVED1,
  21. RESERVED2,
  22. RESERVED3,
  23. RESERVED4,
  24. RESERVED5,
  25. RESERVED6,
  26. RESERVED7,
  27. RESERVED8,
  28. RESERVED9,
  29. RESERVED10,
  30. /* Beyond this point is reserved for application use, e.g.
  31. enum {
  32. MYAPP_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM,
  33. MYAPP_CATEGORY_AWESOME2,
  34. MYAPP_CATEGORY_AWESOME3,
  35. ...
  36. };
  37. */
  38. CUSTOM,
  39. }
  40. LogPriority :: enum c.int {
  41. DEFAULT = 0, // CUSTOM ONE
  42. VERBOSE = 1,
  43. DEBUG,
  44. INFO,
  45. WARN,
  46. ERROR,
  47. CRITICAL,
  48. NUM,
  49. }
  50. LogOutputFunction :: proc "c" (userdata: rawptr, category: LogCategory, priority: LogPriority, message: cstring)
  51. @(default_calling_convention="c", link_prefix="SDL_")
  52. foreign lib {
  53. LogSetAllPriority :: proc(priority: LogPriority) ---
  54. LogSetPriority :: proc(category: c.int, priority: LogPriority) ---
  55. LogGetPriority :: proc(category: c.int) -> LogPriority ---
  56. LogResetPriorities :: proc() ---
  57. Log :: proc(fmt: cstring, #c_vararg args: ..any) ---
  58. LogVerbose :: proc(category: c.int, fmt: cstring, #c_vararg args: ..any) ---
  59. LogDebug :: proc(category: c.int, fmt: cstring, #c_vararg args: ..any) ---
  60. LogInfo :: proc(category: c.int, fmt: cstring, #c_vararg args: ..any) ---
  61. LogWarn :: proc(category: c.int, fmt: cstring, #c_vararg args: ..any) ---
  62. LogError :: proc(category: c.int, fmt: cstring, #c_vararg args: ..any) ---
  63. LogCritical :: proc(category: c.int, fmt: cstring, #c_vararg args: ..any) ---
  64. LogMessage :: proc(category: c.int, priority: LogPriority, fmt: cstring, #c_vararg args: ..any) ---
  65. // LogMessageV :: proc(category: c.int, priority: LogPriority, fmt: cstring, ap: va_list) ---
  66. LogGetOutputFunction :: proc(callback: ^LogOutputFunction, userdata: ^rawptr) ---
  67. LogSetOutputFunction :: proc(callback: LogOutputFunction, userdata: rawptr) ---
  68. }