SDL_SetLogPriorityPrefix(3)

πŸ’– SDL_SetLogPriorityPrefix β€” the SDL3 glow-up for your log messages πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, and today we're doing a little ✨aesthetic✨ upgrade to your logs. this one's called SDL_SetLogPriorityPrefix, and no cap, it's the glow-up your terminal output has been begging for πŸŽ€


🌸 NAME 🌸

SDL_SetLogPriorityPrefix β€” sets the text that gets prepended to log messages of a given priority. like, the little label that shows up in front of the drama. πŸ’…


✨ SYNOPSIS ✨

#include <SDL3/SDL_log.h>

bool SDL_SetLogPriorityPrefix(SDL_LogPriority priority, const char *prefix);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜• β€” by default, SDL_LOG_PRIORITY_INFO and anything below it get no prefix at all, and SDL_LOG_PRIORITY_WARN and anything higher get a prefix showing off their priority, like "WARNING: ". main character energy, honestly.

this function lets you change that prefix for whichever priority you want.

and the bestie behavior? 🫢 this function makes a copy of its string argument, prefix, so you do not need to keep the value of prefix alive after the call returns. it's giving responsible. it's giving self-sufficient. it's giving you can let that buffer go, queen.


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • priority β€” the SDL_LogPriority you wanna modify. pick your fighter πŸ’œ
  • prefix β€” the prefix to use for that log priority, or NULL to use no prefix. yes, NULL is a valid vibe, that's the "silent but deadly" option πŸ™ˆ

πŸ”₯ RETURN VALUE πŸ”₯

returns true on success or false on failure β€” and if it fails, call SDL_GetError() for more information. literally always check, bestie, don't just assume it ate 😭


πŸ’œ THREAD SAFETY πŸ’œ

it is safe to call this function from any thread. go off, multithreaded icon πŸ‘‘


⭐ AVAILABILITY ⭐

this function is available since SDL 3.2.0. so if you're on something older... babes. time to update. 🧚


🌈 SEE ALSO 🌈


ngl, prefixing your logs is lowkey the most underrated self-care. your future self reading a crash log at 3am will thank you πŸ’–

and that's the whole page, bestie!! this lil slice of SDL 3.4.18 knowledge comes to you courtesy of Simple Directmedia Layer β€” stay logged, stay iconic, and may all your priorities have the cutest prefixes πŸŒΈβœ¨πŸ’…

πŸ“¦ where this page comes from