Sorry,
I forgot the patch.
tito.
Tito Flagella wrote:
> I'm enclosing a patch for better syslog support in squid. The patch is
> for a squid-2.4.STABLE7 release. If needed, I can eventually produce
> the patch for more recent releases.
>
> The patch consists in support for an optional parameter to the '-s'
> option. If you don't specify any value for the 's' option, the
> behaviour is the same it was before. Setting "-s2", all other logs are
> sent to syslog, as LOG_INFO, while debug logs continue to be sent as
> LOG_WARNING or LOG_NOTICE. To let programs to recollect useful data
> (eg. for access statistics), a string identifying the log-type is
> prepended to the usual squid output (access, store or logs)
>
> Here is an example of use:
>
> squid -s2 -D
>
> Sample syslog output:
>
> Dec 10 16:49:48 impresario squid[14271]: idnsSendQuery: FD 5: sendto:
> (101) Network is unreachable
> Dec 10 16:49:48 impresario squid[14271]: WARNING: redirector #1 (FD 7)
> exited
> Dec 10 16:49:53 impresario squid[14271]: idnsCheckQueue: ID 2: giving
> up after 1 tries and 5.1 seconds
> Dec 10 16:49:53 impresario squid[14271]: access 1039535393.664 5070
> 127.0.0.1 TCP_MISS/503 1084 GET http://localhost/root/tel - NONE/- -
> Dec 10 16:49:53 impresario squid[14271]: store 1039535393.664 RELEASE
> -1 FFFFFFFF 10A653A45766F80D57EA20E7B6D4ED8D 503 -1
> -1 -1
>
> Hope it helps,
>
> tito.
>
diff -b -u -r squid-2.4.STABLE7.orig/src/access_log.c squid-2.4.STABLE7/src/access_log.c
--- squid-2.4.STABLE7.orig/src/access_log.c Fri Jan 12 01:51:44 2001
+++ squid-2.4.STABLE7/src/access_log.c Mon Dec 9 19:22:59 2002
@@ -263,6 +263,7 @@
safe_free(ereq);
safe_free(erep);
} else {
+ if (opt_syslog_enable <= 1)
logfilePrintf(logfile, "\n");
}
logfileFlush(logfile);
diff -b -u -r squid-2.4.STABLE7.orig/src/logfile.c squid-2.4.STABLE7/src/logfile.c
--- squid-2.4.STABLE7.orig/src/logfile.c Tue Apr 17 22:36:08 2001
+++ squid-2.4.STABLE7/src/logfile.c Mon Dec 9 19:23:38 2002
@@ -146,6 +146,7 @@
{
va_list args;
char buf[8192];
+ char buf1[8292];
int s;
#if STDC_HEADERS
va_start(args, fmt);
@@ -156,8 +157,30 @@
lf = va_arg(args, Logfile *);
fmt = va_arg(args, char *);
#endif
+ if (opt_syslog_enable > 1 ) {
+ if (strcmp(lf->path,"/dev/null")) {
+ char * logType;
+
+ if ( !strcmp(lf->path, Config.Log.access) )
+ logType = "access";
+ else if ( !strcmp(lf->path, Config.Log.log) )
+ logType = "log";
+ else if ( !strcmp(lf->path, Config.Log.store) )
+ logType = "store";
+ else if ( !strcmp(lf->path, Config.Log.swap) )
+ logType = "swap";
+ else
+ logType = "unknown";
+
+ s = vsnprintf(buf, 8192, fmt, args);
+ snprintf(buf1, 8292, "%s %s", logType, buf);
+ syslog(LOG_INFO, buf1);
+ }
+ } else {
s = vsnprintf(buf, 8192, fmt, args);
logfileWrite(lf, buf, (size_t) s);
+ }
+
va_end(args);
}
diff -b -u -r squid-2.4.STABLE7.orig/src/main.c squid-2.4.STABLE7/src/main.c
--- squid-2.4.STABLE7.orig/src/main.c Sun May 20 02:09:59 2001
+++ squid-2.4.STABLE7/src/main.c Tue Dec 10 14:38:23 2002
@@ -115,7 +115,7 @@
extern char *optarg;
int c;
- while ((c = getopt(argc, argv, "CDFNRSVYXa:d:f:hk:m::su:vz?")) != -1) {
+ while ((c = getopt(argc, argv, "CDFNRSVYXa:d:f:hk:m::s::u:vz?")) != -1) {
switch (c) {
case 'C':
opt_catch_signals = 0;
@@ -206,6 +206,9 @@
#endif
}
case 's':
+ if (optarg) {
+ opt_syslog_enable = atoi(optarg);
+ } else
opt_syslog_enable = 1;
break;
case 'u':
Received on Tue Dec 10 2002 - 10:27:36 MST
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:19:00 MST