From b6c5d998a8dcac443cfa80d756e6dfc0c367d64a Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 4 Aug 2005 15:35:27 +0000 Subject: mysql connect error messages enhanced (now go to the log themselves) --- Makefile | 6 +++--- syslogd.c | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index c2b6b12e..67b9ffde 100644 --- a/Makefile +++ b/Makefile @@ -17,8 +17,8 @@ CC= gcc # enables the MySQL code. By default, that one is commented out # change the comment chars to activate it if you need MySQL! # In this case, also look down further to uncomment the libs -CFLAGS= $(RPM_OPT_FLAGS) -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce $(NOLARGEFILE) -#CFLAGS= $(RPM_OPT_FLAGS) -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce -DWITH_DB -I/usr/local/include $(NOLARGEFILE) +#CFLAGS= $(RPM_OPT_FLAGS) -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce $(NOLARGEFILE) +CFLAGS= $(RPM_OPT_FLAGS) -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce -DWITH_DB -I/usr/local/include $(NOLARGEFILE) LDFLAGS= -s INSTALL = install @@ -26,7 +26,7 @@ BINDIR = /usr/sbin MANDIR = /usr/share/man # Uncomment the following to use mysql. -#LIBS = -lmysqlclient -L/usr/local/lib/mysql +LIBS = -lmysqlclient -L/usr/local/lib/mysql # There is one report that under an all ELF system there may be a need to # explicilty link with libresolv.a. If linking syslogd fails you may wish diff --git a/syslogd.c b/syslogd.c index 3c16ce16..da9361e6 100644 --- a/syslogd.c +++ b/syslogd.c @@ -2416,7 +2416,7 @@ int main(argc, argv) * release. Value 1 might be used if you would like to keep debug * mode enabled during testing. */ - debugging_on = 0; + debugging_on = 1; } /* * Send a signal to the parent to it can terminate. @@ -5480,6 +5480,7 @@ void writeMySQL(register struct filed *f) */ void DBErrorHandler(register struct filed *f) { + char errMsg[512]; /* TODO: * NO DB connection -> Can not log to DB * -------------------- @@ -5503,8 +5504,11 @@ void DBErrorHandler(register struct filed *f) * * Think about diffrent "delay" for diffrent errors! */ - dprintf("db error no: %d\n", mysql_errno(&f->f_hmysql)); - dprintf("db error: %s\n", mysql_error(&f->f_hmysql)); + errno = 0; + snprintf(errMsg, sizeof(errMsg)/sizeof(char), + "db error (%d): %s\n", mysql_errno(&f->f_hmysql), + mysql_error(&f->f_hmysql)); + logerror(errMsg); /* Enable "delay" */ f->f_timeResumeOnError = time(&f->f_timeResumeOnError) + _DB_DELAYTIMEONERROR ; f->f_iLastDBErrNo = mysql_errno(&f->f_hmysql); -- cgit