来源:http://www.gnu.org/software/libc/manual/html_node/setlogmask.html
The symbols referred to in this section are declared in the file syslog.h.
setlogmasksets a mask (the “logmask”) that determines which futuresyslogcalls shall be ignored. If a program has not calledsetlogmask,syslogdoesn't ignore any calls. You can usesetlogmaskto specify that messages of particular priorities shall be ignored in the future.A
setlogmaskcall overrides any previoussetlogmaskcall.Note that the logmask exists entirely independently of opening and closing of Syslog connections.
Setting the logmask has a similar effect to, but is not the same as, configuring Syslog. The Syslog configuration may cause Syslog to discard certain messages it receives, but the logmask causes certain messages never to get submitted to Syslog in the first place.
mask is a bit string with one bit corresponding to each of the possible message priorities. If the bit is on,
sysloghandles messages of that priority normally. If it is off,syslogdiscards messages of that priority. Use the message priority macros described in syslog; vsyslog and theLOG_MASKto construct an appropriate mask value, as in this example:LOG_MASK(LOG_EMERG) | LOG_MASK(LOG_ERROR)or
~(LOG_MASK(LOG_INFO))There is also a
LOG_UPTOmacro, which generates a mask with the bits on for a certain priority and all priorities above it:LOG_UPTO(LOG_ERROR)The unfortunate naming of the macro is due to the fact that internally, higher numbers are used for lower message priorities.
注:priorities 是facilities 和levels的组合
本文深入探讨了syslog中setlogmask函数的用途与实现原理,解释了如何通过设置logmask来忽略特定优先级的消息,以及与syslog配置的区别。文章还提供了构建合适的mask值的方法,并介绍了相关宏的使用。
1219

被折叠的 条评论
为什么被折叠?



