From 800db596dbfd0c9a657609fd4a666ebf60f25594 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 25 Jan 2008 19:43:10 +0000 Subject: added debug-support environment variable RSYSLOG_DEBUGLOG --- debug.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'debug.c') diff --git a/debug.c b/debug.c index c7f5e408..1577311d 100644 --- a/debug.c +++ b/debug.c @@ -6,6 +6,11 @@ * * File begun on 2008-01-22 by RGerhards * + * Some functions are controlled by environment variables: + * + * RSYSLOG_DEBUGLOG * if set, a debug log file is written + * to that location + * * There is some in-depth documentation available in doc/dev_queue.html * (and in the web doc set on http://www.rsyslog.com/doc). Be sure to read it * if you are getting aquainted to the object. @@ -54,8 +59,8 @@ static int bLogFuncFlow = 0; /* shall the function entry and exit be logged to t static int bPrintFuncDBOnExit = 0; /* shall the function entry and exit be logged to the debug log? */ static int bPrintMutexAction = 0; /* shall mutex calls be printed to the debug log? */ static int bPrintTime = 1; /* print a timestamp together with debug message */ -static char *pszAltDbgFileName = "/home/rger/proj/rsyslog/log"; /* if set, debug output is *also* sent to here */ -static FILE *altdbg; /* and the handle for alternate debug output */ +static char *pszAltDbgFileName = NULL; /* if set, debug output is *also* sent to here */ +static FILE *altdbg = NULL; /* and the handle for alternate debug output */ static FILE *stddbg; //static dbgFuncDB_t pCurrFunc; @@ -748,10 +753,10 @@ dbgprintf(char *fmt, ...) if(altdbg != NULL) fprintf(altdbg, "%s", pszWriteBuf); */ fwrite(pszWriteBuf, lenWriteBuf, 1, stddbg); - fwrite(pszWriteBuf, lenWriteBuf, 1, altdbg); + if(altdbg != NULL) fwrite(pszWriteBuf, lenWriteBuf, 1, altdbg); fflush(stddbg); - fflush(altdbg); + if(altdbg != NULL) fflush(altdbg); pthread_cleanup_pop(1); } @@ -864,6 +869,9 @@ rsRetVal dbgClassInit(void) //sigaction(SIGUSR2, &sigAct, NULL); sigaction(SIGUSR1, &sigAct, NULL); + pszAltDbgFileName = getenv("RSYSLOG_DEBUGLOG"); +printf("dbg fl: %s\n", pszAltDbgFileName); + stddbg = stdout; if(pszAltDbgFileName != NULL) { /* we have a secondary file, so let's open it) */ -- cgit