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_EMERGLOG_ALERTLOG_CRITLOG_ERRLOG_WARNINGLOG_NOTICELOG_INFOLOG_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
- Copyright 2001, Andries E. Brouwer <aeb@cwi.nl>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms