diff -r -U4 rp-l2tp-0.4/debug.c rp-l2tp-0.4+syslog/debug.c --- rp-l2tp-0.4/debug.c 2002-09-30 20:45:00.000000000 +0100 +++ rp-l2tp-0.4+syslog/debug.c 2009-11-02 14:59:19.000000000 +0000 @@ -19,8 +19,9 @@ #include "l2tp.h" #include #include #include +#include #include #define AVPCASE(x) case AVP_ ## x: return #x #define MSGCASE(x) case MESSAGE_ ## x: return #x @@ -28,9 +29,12 @@ static unsigned long debug_mask = 0; /* Big bang is when the universe started... set by first call to db */ +#if 0 static struct timeval big_bang = {0, 0}; +#endif +static int big_bang = 0; /********************************************************************** * %FUNCTION: debug_avp_type_to_str * %ARGUMENTS: @@ -167,13 +171,15 @@ void l2tp_db(int what, char const *fmt, ...) { va_list ap; +#if 0 struct timeval now; long sec_diff, usec_diff; +#endif - if (!(debug_mask & what)) return; - + if (what > 0 && !(debug_mask & what)) return; +#if 0 gettimeofday(&now, NULL); if (!big_bang.tv_sec) { big_bang = now; @@ -188,12 +194,21 @@ } /* Convert to seconds.milliseconds */ usec_diff /= 1000; +#endif + + if (!big_bang) { + openlog("rp-l2tpd", LOG_NDELAY|LOG_NOWAIT|LOG_PID, LOG_DAEMON); + big_bang = 1; + } va_start(ap, fmt); +#if 0 fprintf(stderr, "%4ld.%03ld ", sec_diff, usec_diff); vfprintf(stderr, fmt, ap); +#endif + vsyslog(what == 0 ? LOG_NOTICE : LOG_DEBUG, fmt, ap); va_end(ap); } /********************************************************************** diff -r -U4 rp-l2tp-0.4/main.c rp-l2tp-0.4+syslog/main.c --- rp-l2tp-0.4/main.c 2002-09-30 20:45:00.000000000 +0100 +++ rp-l2tp-0.4+syslog/main.c 2009-11-02 14:58:38.000000000 +0000 @@ -111,12 +111,14 @@ if (i > 2) close(i); } } + l2tp_db(0, "%s", "startup complete"); while(1) { i = Event_HandleEvent(es); if (i < 0) { fprintf(stderr, "Event_HandleEvent returned %d\n", i); + l2tp_db(0, "Event_HandleEvent returned %d", i); l2tp_cleanup(); exit(EXIT_FAILURE); } } diff -r -U4 rp-l2tp-0.4/utils.c rp-l2tp-0.4+syslog/utils.c --- rp-l2tp-0.4/utils.c 2002-09-30 20:45:00.000000000 +0100 +++ rp-l2tp-0.4+syslog/utils.c 2009-11-02 14:58:58.000000000 +0000 @@ -169,8 +169,9 @@ void l2tp_die(void) { fprintf(stderr, "FATAL: %s\n", errmsg); + l2tp_db(0, "fatal error: %s", errmsg); l2tp_cleanup(); exit(1); }