QB_LOG_FORMAT_SET(3)

πŸ’– QB_LOG_FORMAT_SET(3) πŸ’–

okay bestie, so this is a page straight out of the libqb Programmer's Manual, and it's literally about making your log messages look cute (or at least look how you want). let's get into it 🫢


✨ NAME ✨

qb_log_format_set β€” Set the format specifiers. that's it, that's the whole job πŸ’…


🌸 SYNOPSIS 🌸

#include <qb/qblog.h>

void qb_log_format_set(
    int32_t       t,
    const char   *format
);

πŸ¦‹ DESCRIPTION πŸ¦‹

so you're passing in a format string, and inside it there are these little magic tokens that start with a %. every one of them turns into a piece of info about the log message. it's giving ✨template✨. here's the full roster, no skips, no gatekeeping:

  • %n β€” FUNCTION NAME
  • %f β€” FILENAME
  • %l β€” FILELINE
  • %p β€” PRIORITY
  • %t β€” TIMESTAMP
  • %T β€” TIMESTAMP with milliseconds
  • %b β€” BUFFER
  • %g β€” TAGS
  • %N β€” name (passed into qb_log_init)
  • %P β€” PID
  • %H β€” hostname

and here's the glow-up detail: any number you put between the % and the character tells it the field length, so it'll pad or chop that field for you. iconic behavior, honestly πŸ‘‘


πŸ’œ NOTE πŸ’œ

⚠️ listen up because this one is important β€” some of these fields are immediately evaluated and remembered for performance reasons. so when your log messages carry PIDs (and no, that is not the default), you have to reinvoke this function after fork (clone) in the respective children. like, the remembered value won't magically update itself, bestie, it's frozen 😭. if you're already linking with libpthread, registering a pthread_atfork callback could be useful for exactly this.

πŸŽ€ SEE ALSO πŸŽ€

the whole friend group, fr fr:


Copyright (c) 2017 Red Hat, Inc.


and that's the whole page bestie, you ate that πŸ’… ok bye, this was LIBQB, version dated 2025-09-16, and it's QB_LOG_FORMAT_SET(3) β€” go format something gorgeous βœ¨πŸ’–

πŸ“¦ where this page comes from