head 1.5; access; symbols FSL_1_7_0:1.5 FSL_1_6_1:1.5 FSL_1_6_0:1.5 FSL_1_6b2:1.5 FSL_1_6b1:1.5 FSL_1_5_0:1.5 FSL_1_5a3:1.5 FSL_1_5a2:1.5 FSL_1_5a1:1.5 FSL_1_4_0:1.5 FSL_1_4b1:1.5 FSL_1_4a1:1.5 FSL_1_3_0:1.5 FSL_1_3b1:1.5 FSL_1_2_1:1.5 FSL_1_2_0:1.5 FSL_1_1_0:1.5 FSL_1_1b1:1.5 FSL_1_0_8:1.4 FSL_1_0_7:1.4 FSL_1_0_6:1.4 FSL_1_0_5:1.4 FSL_1_0_4:1.4 FSL_1_0_3:1.4 FSL_1_0_2:1.4 FSL_1_0_1:1.4 FSL_1_0_0:1.4 FSL_0_9_0:1.4 FSL_0_1_12:1.4 FSL_0_1_11:1.4 FSL_0_1_10:1.4 FSL_0_1_9:1.4 FSL_0_1_8:1.4 FSL_0_1_7:1.4 FSL_0_1_6:1.4 FSL_0_1_5:1.4 FSL_0_1_1:1.2; locks; strict; comment @ * @; 1.5 date 2003.05.20.15.47.23; author thl; state Exp; branches; next 1.4; 1.4 date 2002.07.24.15.29.01; author thl; state Exp; branches; next 1.3; 1.3 date 2002.07.23.14.37.50; author thl; state Exp; branches; next 1.2; 1.2 date 2002.07.18.15.18.30; author thl; state Exp; branches; next 1.1; 1.1 date 2002.07.09.09.42.09; author rse; state Exp; branches; next ; desc @@ 1.5 log @- improve prefixing by renaming variables l2_fslenv > fsldebug_l2_env l2_fslnch > fsldebug_l2_nch triedopenfsldebug > fsldebug_transientproblem openfsldebugpermanenterror > fsldebug_permanentproblem - add function fsldebugcreate() - rename functions and slightly change their operation to work in a stealth mode for LOG_NDELAY support openfsldebug() > fsl closefsllog() > fsldebugdestroy() - make fsldebug() a metafunction and split the old functionality into fsldebugl2() for l2 and fsldebugf2() for stderr filedescriptor - improve prefixing by adding debugging prototypes to support fsldebug() calling fsldebugcreate() which uses fsldebug() for logging static void fsldebugcreate (void); static void fsldebug (l2_level_t, const char *, ...); static int fsldebugl2 (l2_level_t, const char *, va_list); static int fsldebugf2 (l2_level_t, const char *, va_list); static void fsldebugdestroy(void); - change default for delayopen to TRUE as user has to use LOG_NDELAY to force immediate open. - improve handling of NULL strings when debugging - unify debugging messages on entry to captured functions using common prefix 'fsl in ...' - obey LOG_NDELAY on fsl debugging as well - add filedescriptor consumption checks to test suite - remove confusing use of the word "error" in test suite messages - improve Makefile to prepare and detect empty files - tested on FreeBSD, Linux and Solaris - not intended for release - further modifications are underway @ text @ #include #include #include /* open(2) */ #include /* close(2) */ #include /* exit(3) */ static void pexit(const char *msg, int rc) { fprintf(stderr, "ERROR: %s\n", msg); exit(rc); } static int tryfd(void) { int fd; if ((fd = open("/dev/null", O_RDONLY)) == -1) pexit("internal - cannot open /dev/null for reading", 1); if (close(fd) == -1) pexit("internal - cannot close(2)", 1); return fd; } int main(int argc, char *argv[]) { int fd1, fd2; fd1 = tryfd(); setlogmask(LOG_UPTO(LOG_ERR)); openlog("mail", LOG_PID, LOG_LOCAL0); /* this must not consume a filedescriptor; LOG_NDELAY and break it */ setlogmask(LOG_UPTO(LOG_ERR)); fd2 = tryfd(); if (fd1 != fd2) pexit("testsuite - filedescriptor allocated where it should not", 2); closelog(); fd1 = tryfd(); openlog("mail", LOG_PID, LOG_LOCAL1); if (fd1 != tryfd()) pexit("testsuite - filedescriptor allocated where it should not", 2); setlogmask(LOG_UPTO(LOG_ERR)); if (fd1 != tryfd()) pexit("testsuite - filedescriptor allocated where it should not", 2); syslog(LOG_ALERT, "one"); syslog(LOG_ALERT, "two"); closelog(); openlog("mail", LOG_PID|LOG_NDELAY, LOG_LOCAL0); syslog(LOG_ALERT, "who: internal 23\n"); setlogmask(LOG_UPTO(LOG_ERR)); syslog(LOG_INFO|LOG_LOCAL2, "foobar: %m"); syslog(LOG_EMERG, "syslogging LOG_EMERG %d", LOG_EMERG ); syslog(LOG_ALERT, "syslogging LOG_ALERT %d", LOG_ALERT ); syslog(LOG_CRIT, "syslogging LOG_CRIT %d", LOG_CRIT ); syslog(LOG_ERR, "syslogging LOG_ERR %d", LOG_ERR ); syslog(LOG_WARNING, "syslogging LOG_WARNING %d", LOG_WARNING); syslog(LOG_NOTICE, "syslogging LOG_NOTICE %d", LOG_NOTICE ); syslog(LOG_INFO, "syslogging LOG_INFO %d", LOG_INFO ); syslog(LOG_DEBUG, "syslogging LOG_DEBUG %d", LOG_DEBUG ); closelog(); return 0; } @ 1.4 log @added solaris and linux compatiblity; improved readability of traces @ text @d4 20 d27 22 a48 1 syslog(LOG_INFO, "Connection from host %s", "foo.bar.dom"); d50 1 a50 1 syslog(LOG_ALERT, "who: internal error 23\n"); d52 1 a52 1 syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m"); d62 1 @ 1.3 log @added userlevel debugging through FSL_DEBUG environment variable @ text @d8 1 a8 1 openlog("mail", LOG_PID|LOG_NDELAY, LOG_FTP); @ 1.2 log @flush with lots of debugging stuff @ text @d20 1 @ 1.1 log @First cut for new-born OSSP fsl, a faking syslog(3) API library. It is internally based (and contains) OSSP l2 and OSSP cfg. @ text @d12 8 d22 7 @