pr_fmt(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… pr_fmt(9) β€” the Kernel API Manual, bestie edition πŸŽ€

okay so like, quick vibe check: this is a page from the Kernel API Manual and it's about pr_fmt, which is genuinely one of those tiny things that makes a whole file look put-together. main character macro energy fr fr ✨


🌸 NAME 🌸

pr_fmt β€” the lil macro the pr_*() macros use to generate the printk format string πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

pr_fmt (fmt );

✨ ARGUMENTS ✨

  • fmt β€” the format string that got passed in from a pr_*() macro. that's it. that's the whole argument 🫢

πŸ’œ DESCRIPTION πŸ’œ

okay so here's the tea: this macro is how you generate a unified format string for all the pr_*() macros. like, one string to rule them all, no cap πŸ‘‘

the classic use case β€” the one everybody does β€” is prefixing every single pr_*() message in a file with a common string. so instead of your logs looking like a chaotic group chat with no names, every message is tagged. iconic behaviour tbh.

for example, defining this at the top of a source file:

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

would prefix all pr_info, pr_emerg... messages in the file with the module name. literally all of them. slay πŸ”₯

ngl this is the kind of one-liner that makes debugging at 3am feel slightly less cursed. slightly. 😭

🌈 SEE ALSO 🌈

the whole pr_* friend group, assembled πŸ’…πŸ“


aaaand that's the page bestie πŸ§šπŸ’« huge shoutout to ./include/linux for hosting this one, dated October 2026 β€” go forth and prefix your logs, you're gonna eat πŸ’–πŸ‘‘

πŸ“¦ where this page comes from