SDL_LogOutputFunction(3type)

πŸ’– SDL_LogOutputFunction β€” a page from the SDL3 DATATYPES corner of the manual πŸ’–

okay bestie, gather round, because today we're talking about a type β€” specifically SDL_LogOutputFunction from SDL3. It's the prototype for the log output callback function, and yes it's exactly as iconic as it sounds. πŸŽ€


✨ SYNOPSIS ✨

#include <SDL3/SDL_log.h>

typedef void (SDLCALL *SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message);

like, look at her. a whole function pointer typedef. she's serving void, she's serving SDLCALL, she's serving four parameters. no notes. πŸ’…


🌸 DESCRIPTION 🌸

so here's the tea: this function gets called by SDL whenever there's new text to be logged. that's the whole job. new log text shows up β†’ your callback runs. slay. ✨

and here's the important bit, the part you cannot skip, the part that is genuinely giving main character energy: a mutex is held, so this function is never called by more than one thread at once. like, SDL has got you. no race conditions on this one, babe. 🫢


πŸ¦‹ FUNCTION PARAMETERS πŸ¦‹

  • userdata β€” literally whatever you passed as userdata to SDL_SetLogOutputFunction(). it comes right back to you. it's giving "you get out what you put in" but make it a pointer. πŸ’«
  • category β€” the category of the message. yes bestie, it has a category. 🏷️
  • priority β€” the priority of the message. how urgent is this log? she'll tell you. πŸ”₯
  • message β€” the message being output. the actual words. the content. the moment. πŸ‘‘

⭐ AVAILABILITY ⭐

this datatype has been available since SDL 3.2.0. so if you're on something older, no she is not there, sorry babe. 😭


πŸ’€ reminder: the mutex detail in DESCRIPTION is not a vibe, it's a guarantee. don't go assuming you need to lock around your own callback for the sake of SDL's threading. that's already handled.

and that's the page, bestie!! πŸ’œ this one comes to you from Simple Directmedia Layer β€” SDL 3.4.18 edition β€” and it's a SDL_LogOutputFunction(3type) situation through and through. go log something gorgeous. πŸ“πŸ§šπŸ’–

πŸ“¦ where this page comes from