setlogmask(3)

✨ setlogmask(3) ✨

okay bestie, welcome to the manual page for setlogmask β€” it's a libc classic, section 3, and honestly it's giving "small function, big power". let's get into it πŸ’…


🌸 NAME 🌸

setlogmask β€” set that log priority mask, periodt


πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc). yeah she's built in, no extra packages, no downloads, we love a low-maintenance icon 🫢


✨ SYNOPSIS ✨

#include <syslog.h>

int setlogmask(int mask);

πŸ’– DESCRIPTION πŸ’–

so here's the tea: every process has a lil log priority mask, and that mask decides which calls to syslog(3) actually get logged. everything else? ignored. gone. not invited to the function. πŸ™ˆ

logging is enabled for the priorities that have the corresponding bit set in mask. and the initial mask? it's set so that logging is enabled for all priorities. iconic default behaviour, truly.

the setlogmask() function sets this logmask for the calling process, and returns the previous mask. and if the mask argument is 0, the current logmask is not modified β€” nope, it stays exactly as it was, no notes.

the eight priorities are:

  • LOG_EMERG
  • LOG_ALERT
  • LOG_CRIT
  • LOG_ERR
  • LOG_WARNING
  • LOG_NOTICE
  • LOG_INFO
  • LOG_DEBUG

the bit corresponding to a priority p is LOG_MASK(p). and some systems also provide a macro LOG_UPTO(p) for the mask of all priorities in the above list up to and including p. handy!! πŸŽ€


πŸ” RETURN VALUE πŸ”

this function returns the previous log priority mask. that's it, that's the whole return value, she's simple and she knows it.


πŸ’€ ERRORS πŸ’€

None. literally zero. not a single error. bestie is flawless, not me saying that 😭


πŸ¦‹ ATTRIBUTES πŸ¦‹

for an explanation of the terms used in this section, see attributes(7). πŸ’œ

  • Interface: setlogmask()
    • Attribute: Thread safety
    • Value: MT-Unsafe race:LogMask
⚠️ ok so heads up: that value is MT-Unsafe race:LogMask. translation? there's a race condition situation with the log mask across threads. be careful out there, especially if you're threading 🧚

πŸ‘‘ STANDARDS πŸ‘‘

POSIX.1-2008. certified, official, on the list. ⭐


🌈 HISTORY 🌈

POSIX.1-2001. she's been around a minute, a true veteran queen.

and psst β€” LOG_UPTO() will be included in the next release of the POSIX specification (Issue 8). so it's coming, it's just not here yet, don't @ me. ✨


πŸ‘€ SEE ALSO πŸ‘€


and that's the whole page babes πŸ’– this was pulled straight from Linux man-pages 6.20, dated 2026-02-08 β€” go forth, mask your priorities, slay your logs πŸŽ€πŸ¦‹βœ¨

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ“œ the page's license: Linux-man-pages-copyleft
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms