summaryrefslogtreecommitdiffstats
path: root/debug.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-01-25 19:43:10 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-01-25 19:43:10 +0000
commit800db596dbfd0c9a657609fd4a666ebf60f25594 (patch)
treed69078adc4122f1e3a77d9c923ccf47e0fdcee43 /debug.c
parent15eb2b29c923c705788c2114067498c2cb90f82e (diff)
downloadrsyslog-800db596dbfd0c9a657609fd4a666ebf60f25594.tar.gz
rsyslog-800db596dbfd0c9a657609fd4a666ebf60f25594.tar.xz
rsyslog-800db596dbfd0c9a657609fd4a666ebf60f25594.zip
added debug-support environment variable RSYSLOG_DEBUGLOG
Diffstat (limited to 'debug.c')
-rw-r--r--debug.c16
1 files changed, 12 insertions, 4 deletions
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) */