This is the mail archive of the
glibc-linux@ricardo.ecn.wfu.edu
mailing list for the glibc project.
setlogmask() help requested
- To: "'glibc-linux@ricardo.ecn.wfu.edu'" <glibc-linux@ricardo.ecn.wfu.edu>
- Subject: setlogmask() help requested
- From: "Wright, Shayne (SAHO)" <Shaynew@saho.org>
- Date: Thu, 17 Jun 1999 08:33:39 -0600
- Reply-To: glibc-linux@ricardo.ecn.wfu.edu
Hello
First off, I am not sure if my problem is related to the glibc library, the
C code, or to my
system setup, so I might not be asking my question of the correct mailing
list. If this is the case, please help me determine where I should look for
advice: gnu-egcs, alt.linux.*, etc.
My problem is with the following code segment, or more likely, my
expectation of the setlogmask function. According to the information I have,
I expect that:
logmask = setlogmask(LOG_UPTO(LOG_NOTICE)) will set the logmask such that
all log levels below LOG_NOTICE will be disregarded upon subsequent calls to
syslog.
For a test I have the following test program.
---
logmask.c
---
#include <syslog.h>
#include <stdio.h>
#include <unistd.h>
int main()
{
int logmask;
openlog("logmask", LOG_PID|LOG_CONS, LOG_USER);
syslog(LOG_INFO, "information message, pid = %d", getpid());
syslog(LOG_DEBUG, "debug message, should appear");
logmask = setlogmask(LOG_UPTO(LOG_NOTICE));
syslog(LOG_DEBUG, "debug message, should not appear");
exit (0);
}
Now my expectation is that the first LOG_DEBUG call to syslog would be
logged in /var/log/debug, but the second call would not. This is not the
case though. Both calls are logged.
---
tail /var/log/debug
---
Jun 15 21:08:36 jazz logmask[1944]: debug message, should appear
Jun 15 21:08:36 jazz logmask[1944]: debug message, should not appear
Could someone tell me if the problem lies in my code, my expectation of the
code, the development tools, or my Linux system configuration. I can find no
setlogmask man pages on my system, and only limited documentation on the
net.
System details follow:
---
uname -a
---
Linux jazz 2.0.29 #1 Fri Mar 7 18:25:54 PST 1997 i486
---
gcc --version
---
egcs-2.90.29 980515 (egcs-1.0.3 release)
---
ldd logmask
---
libc.so.6 => /lib/libc.so.6 (0x40003000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00000000)
Many thanks,
Take care,
Shayne