syslog(3) first explains the levels with
The level [...] is selected from the following ordered (high to low) list:
LOG_EMERG
LOG_ALERT
[...]
LOG_DEBUG
If "high" in this context means "more severe error", fine, but the
numerical values are of course exactly reversed:
#define LOG_EMERG 0 /* system is unusable */
[...]
#define LOG_DEBUG 7 /* debug-level messages */
But then the setlogmask() paragraph says
[...] the mask for all priorities up to
and including toppri is given by the macro LOG_UPTO(toppri).
"Up to" and "top" refer to the numerical order, not the reverse
order implied by the "ordered (high to low) list".
Example:
setlogmask(LOG_UPTO(LOG_ALERT)) causes LOG_ALERT=0 and LOG_EMERG=1
to be logged, and the others to be ignored, because they are _higher_.
Daniel