sdl_log.odin 2.2 KB

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