# Sample Configuration file for the Internet Junkbuster 2.0
#
-# $Id: config,v 1.4 2001/05/22 17:43:35 oes Exp $
+# $Id: config,v 1.5 2001/05/23 10:39:05 oes Exp $
#
# Table of Contents
# debug 32 # FRC = debug force feature
# debug 64 # REF = debug regular expression filter
# debug 128 # RED = debug fast redirects
+# debug 256 # CLF = Common Log Format
+# debug 4096 # INFO = Startup banner and warnings.
+# debug 8192 # ERROR = Non-fatal errors
+#
+# It is *highly recommended* that you enable ERROR
+# reporting. (debug 8192).
+#
+# The reporting of FATAL errors (i.e. ones which crash
+# JunkBuster) is always on and cannot be disabled.
+#
+# If you want to use CLF, you should set "debug 256" ONLY,
+# do not enable anything else.
#
# Multiple "debug" directives, are OK - they're logical-OR'd
# together.
#
# debug 15 # same as setting the first 4 listed above
#
-# Default: 0, i.e. log nothing but errors and infos
+# Default: 0, i.e. log nothing but fatal errors
#
debug 1
+debug 8192 # Errors - *we highly recommended enabling this*
#
# Junkbuster normally uses "multi-threading", a software technique
-const char errlog_rcs[] = "$Id: errlog.c,v 1.6 2001/05/25 21:55:08 jongfoster Exp $";
+const char errlog_rcs[] = "$Id: errlog.c,v 1.7 2001/05/26 15:21:28 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/errlog.c,v $
*
* Revisions :
* $Log: errlog.c,v $
+ * Revision 1.7 2001/05/26 15:21:28 jongfoster
+ * Activity animation in Win32 GUI now works even if debug==0
+ *
* Revision 1.6 2001/05/25 21:55:08 jongfoster
* Now cleans up properly on FATAL (removes taskbar icon etc)
*
/*
- * LOG_LEVEL_FATAL, LOG_LEVEL_ERROR and LOG_LEVEL_INFO
- * cannot be turned off. (There are some exceptional situations
- * where we need to get a message to the user).
- *
- * FIXME: Do we need LOG_LEVEL_INFO here?
+ * LOG_LEVEL_FATAL cannot be turned off. (There are
+ * some exceptional situations where we need to get a
+ * message to the user).
*/
-#define LOG_LEVEL_MINIMUM (LOG_LEVEL_FATAL | LOG_LEVEL_ERROR | LOG_LEVEL_INFO)
+#define LOG_LEVEL_MINIMUM LOG_LEVEL_FATAL
/* where to log (default: stderr) */
static FILE *logfp = NULL;
static char * logfilename = NULL;
/* logging detail level. */
-static int debug = LOG_LEVEL_MINIMUM;
+static int debug = (LOG_LEVEL_FATAL | LOG_LEVEL_ERROR | LOG_LEVEL_INFO);
static void fatal_error(const char * error_message);
char * src = fmt;
int outc = 0;
long this_thread = 1; /* was: pthread_t this_thread;*/
-\r
-#if defined(_WIN32) && !defined(_WIN_CONSOLE)\r
- /*\r
- * Irrespective of debug setting, a GET/POST/CONNECT makes\r
- * the taskbar icon animate. (There is an option to disable\r
- * this but checking that is handled inside LogShowActivity()).\r
- */\r
- if (loglevel == LOG_LEVEL_GPC)\r
- {\r
- LogShowActivity();\r
+
+#if defined(_WIN32) && !defined(_WIN_CONSOLE)
+ /*
+ * Irrespective of debug setting, a GET/POST/CONNECT makes
+ * the taskbar icon animate. (There is an option to disable
+ * this but checking that is handled inside LogShowActivity()).
+ */
+ if (loglevel == LOG_LEVEL_GPC)
+ {
+ LogShowActivity();
}
-#endif /* defined(_WIN32) && !defined(_WIN_CONSOLE) */\r
-\r
+#endif /* defined(_WIN32) && !defined(_WIN_CONSOLE) */
+
/* verify if loglevel applies to current settings and bail out if negative */
- if(!(loglevel & debug))
+ if ((loglevel & debug) == 0)
{
return;
}
switch (loglevel)
{
- /* FIXME: What about LOG_LEVEL_LOG ??? */
case LOG_LEVEL_ERROR:
outc = sprintf(outbuf, "IJB(%d) Error: ", this_thread);
break;
case LOG_LEVEL_CONNECT:
outc = sprintf(outbuf, "IJB(%d) Connect: ", this_thread);
break;
+ case LOG_LEVEL_LOG:
+ outc = sprintf(outbuf, "IJB(%d) Writing: ", this_thread);
+ break;
case LOG_LEVEL_HEADER:
outc = sprintf(outbuf, "IJB(%d) Header: ", this_thread);
break;
outc = sprintf(outbuf, "IJB(%d) Redirect: ", this_thread);
break;
#endif /* def FAST_REDIRECTS */
+ case LOG_LEVEL_CLF:
+ outc = 0;
+ outbuf[0] = '\0';
+ break;
default:
outc = sprintf(outbuf, "IJB(%d) UNKNOWN LOG TYPE(%d): ", this_thread, loglevel);
break;
outbuf[oldoutc] = '\0';
}
break;
+ case 'N':
+ /* Non-standard: Print a counted string. Takes 2 parameters:
+ * int length, const char * string
+ */
+ ival = va_arg( ap, int );
+ sval = va_arg( ap, char * );
+ if (ival < 0)
+ {
+ ival = 0;
+ }
+ oldoutc = outc;
+ outc += ival;
+ if (outc < BUFSIZ-1)
+ {
+ memcpy(outbuf + oldoutc, sval, ival);
+ }
+ else
+ {
+ outbuf[oldoutc] = '\0';
+ }
+ break;
case 'E':
/* Non-standard: Print error code from errno */
ival = errno;
outbuf[oldoutc] = '\0';
}
break;
+ case 'T':
+ /* Non-standard: Print a Common Log File timestamp */
+ {
+ /*
+ * Write timestamp into tempbuf.
+ *
+ * Complex because not all OSs have tm_gmtoff or
+ * the %z field in strftime()
+ */
+ time_t now;
+ struct tm *tm_now;
+ struct tm gmt;
+ int days, hrs, mins;
+ time (&now);
+ gmt = *gmtime (&now);
+ tm_now = localtime (&now);
+ days = tm_now->tm_yday - gmt.tm_yday;
+ hrs = ((days < -1 ? 24 : 1 < days ? -24 : days * 24) + tm_now->tm_hour - gmt.tm_hour);
+ mins = hrs * 60 + tm_now->tm_min - gmt.tm_min;
+ strftime (tempbuf, BUFSIZ-6, "%d/%b/%Y:%H:%M:%S ", tm_now);
+ sprintf (tempbuf + strlen(tempbuf), "%+03d%02d", mins / 60, abs(mins) % 60);
+ }
+ oldoutc = outc;
+ outc += strlen(tempbuf);
+ if (outc < BUFSIZ-1)
+ {
+ strcpy(outbuf + oldoutc, tempbuf);
+ }
+ else
+ {
+ outbuf[oldoutc] = '\0';
+ }
+ break;
default:
sprintf(outbuf, "IJB(%d) Error: log_error(): Bad format string:\n"
"Format = \"%s\"\n"
#ifndef _ERRLOG_H
#define _ERRLOG_H
-#define ERRLOG_H_VERSION "$Id: errlog.h,v 1.3 2001/05/22 18:46:04 oes Exp $"
+#define ERRLOG_H_VERSION "$Id: errlog.h,v 1.4 2001/05/25 21:56:06 jongfoster Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/errlog.h,v $
*
* Revisions :
* $Log: errlog.h,v $
+ * Revision 1.4 2001/05/25 21:56:06 jongfoster
+ * Added FIXME comment to (broken) LOG_LEVEL_LOG
+ *
* Revision 1.3 2001/05/22 18:46:04 oes
*
* - Enabled filtering banners by size rather than URL
#define LOG_LEVEL_CONNECT 0x0002
#define LOG_LEVEL_IO 0x0004
#define LOG_LEVEL_HEADER 0x0008
-#define LOG_LEVEL_LOG 0x0010 /* FIXME: What for? Need to put in errlog.c. */
+#define LOG_LEVEL_LOG 0x0010
#ifdef FORCE_LOAD
#define LOG_LEVEL_FORCE 0x0020
#endif /* def FORCE_LOAD */
#define LOG_LEVEL_REDIRECTS 0x0080
#endif /* def FAST_REDIRECTS */
+#define LOG_LEVEL_CLF 0x0100 /* Common Log File format */
+
/* Following are always on: */
#define LOG_LEVEL_INFO 0x1000
#define LOG_LEVEL_ERROR 0x2000