* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
* der an comBase beteiligten Autoren finden Sie in der Datei AUTHORS.
*
- * $Id: log.c,v 1.3 2001/12/12 23:31:24 alex Exp $
+ * $Id: log.c,v 1.11 2001/12/29 03:08:49 alex Exp $
*
* log.c: Logging-Funktionen
*
* $Log: log.c,v $
+ * Revision 1.11 2001/12/29 03:08:49 alex
+ * - neue configure-Option "--enable-strict-rfc".
+ *
+ * Revision 1.10 2001/12/27 01:44:49 alex
+ * - die Verwendung von syslog kann nun abgeschaltet werden.
+ *
+ * Revision 1.9 2001/12/26 03:22:16 alex
+ * - string.h wird nun includiert.
+ *
+ * Revision 1.8 2001/12/25 23:13:00 alex
+ * - Versionsstring bei Programmstart verbessert.
+ *
+ * Revision 1.7 2001/12/25 22:04:26 alex
+ * - Aenderungen an den Debug- und Logging-Funktionen.
+ *
+ * Revision 1.6 2001/12/25 19:20:39 alex
+ * - es wird nun die Facility LOG_LOCAL5 zum Loggen verwendet.
+ *
+ * Revision 1.5 2001/12/15 00:07:56 alex
+ * - Log-Level der Start- und Stop-Meldungen angehoben.
+ *
+ * Revision 1.4 2001/12/13 02:04:16 alex
+ * - boesen "Speicherschiesser" in Log() gefixt.
+ *
* Revision 1.3 2001/12/12 23:31:24 alex
* - Zum Loggen wird nun auch syslog verwendet.
*
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
+#include <string.h>
+
+#ifdef USE_SYSLOG
#include <syslog.h>
+#endif
#include <exp.h>
#include "log.h"
GLOBAL VOID Log_Init( VOID )
{
- openlog( PACKAGE, LOG_CONS|LOG_PID, LOG_DAEMON );
- Log( LOG_INFO, PACKAGE" version "VERSION" started.");
+ CHAR txt[64];
+
+ strcpy( txt, "" );
+
+#ifdef USE_SYSLOG
+ if( txt[0] ) strcat( txt, "+" );
+ else strcat( txt, "-" );
+ strcat( txt, "SYSLOG" );
+#endif
+#ifdef STRICT_RFC
+ if( txt[0] ) strcat( txt, "+" );
+ else strcat( txt, "-" );
+ strcat( txt, "RFC" );
+#endif
+#ifdef DEBUG
+ if( txt[0] ) strcat( txt, "+" );
+ else strcat( txt, "-" );
+ strcat( txt, "DEBUG" );
+#endif
+#ifdef SNIFFER
+ if( txt[0] ) strcat( txt, "+" );
+ else strcat( txt, "-" );
+ strcat( txt, "SNIFFER" );
+#endif
+
+#ifdef USE_SYSLOG
+ openlog( PACKAGE, LOG_CONS|LOG_PID, LOG_LOCAL5 );
+#endif
+ Log( LOG_NOTICE, PACKAGE" version "VERSION"%s started.", txt );
} /* Log_Init */
GLOBAL VOID Log_Exit( VOID )
{
- Log( LOG_INFO, PACKAGE" done.");
+ Log( LOG_NOTICE, PACKAGE" done.");
+#ifdef USE_SYSLOG
closelog( );
+#endif
} /* Log_Exit */
CHAR msg[MAX_LOG_MSG_LEN];
va_list ap;
+#ifndef DEBUG
+ if( Level == LOG_DEBUG ) return;
+#endif
+
assert( Format != NULL );
/* String mit variablen Argumenten zusammenbauen ... */
va_start( ap, Format );
vsnprintf( msg, MAX_LOG_MSG_LEN - 1, Format, ap );
- msg[MAX_LOG_MSG_LEN] = '\0';
+ msg[MAX_LOG_MSG_LEN - 1] = '\0';
/* ... und ausgeben */
printf( "[%d] %s\n", Level, msg );
+#ifdef USE_SYSLOG
syslog( Level, msg );
+#endif
va_end( ap );
} /* Log */