--------------------- PatchSet 4787 Date: 2002/08/26 19:32:41 Author: kinkie Branch: customlog Tag: (none) Log: Added dump-logformat function. Members: src/access_log.c:1.16.4.2->1.16.4.3 src/cache_cf.c:1.41.4.3->1.41.4.4 src/protos.h:1.48.4.2->1.48.4.3 Index: squid/src/access_log.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/access_log.c,v retrieving revision 1.16.4.2 retrieving revision 1.16.4.3 diff -u -r1.16.4.2 -r1.16.4.3 --- squid/src/access_log.c 21 Apr 2002 19:34:43 -0000 1.16.4.2 +++ squid/src/access_log.c 26 Aug 2002 19:32:41 -0000 1.16.4.3 @@ -1,6 +1,6 @@ /* - * $Id: access_log.c,v 1.16.4.2 2002/04/21 19:34:43 kinkie Exp $ + * $Id: access_log.c,v 1.16.4.3 2002/08/26 19:32:41 kinkie Exp $ * * DEBUG: section 46 Access Log * AUTHOR: Duane Wessels @@ -486,6 +486,54 @@ #warning "TODO: optimize merging consecutive strings together" } +void +accessLogDumpLogFormat (StoreEntry *entry, const char *name, logformat * definitions) +{ + logformat_token *t; + logformat_token_table_entry *te; + debug(46,0)("accessLogDumpLogFormat called\n"); + + while (definitions!=NULL) { + debug(46,0)("Dumping logformat definition for %s\n",definitions->name); + storeAppendPrintf("logformat %s \"",definitions->name); + t=logformat->format; + while (t!=NULL) { + char ok=0; + switch (t->type) { + /* special cases */ + case LFT_STRING: + storeAppend(entry,t->strarg,strlen(t->strarg)); + break; + /* "simple" tokens which have no extra args */ + case LFT_TIME_SUBSECOND: + storeAppendPrintf(entry,"t#%d",t->iarg); + break; + case LFT_REQUEST_HEADER: + storeAppendPrintf(entry,"sarg); + break; + case LFT_REPLY_HEADER: + storeAppendPrintf(entry,">h{%s}",t->sarg); + break; + default: + te=logformat_token_table; + while (te->config!=NULL) { + if (te->token_type==t->type) { + storeAppend(entry,te->config,strlen(te->config)); + ok=1; + break; + } + te++; + } + /* notreached */ + if (ok==0) + fatal("Internal error while dumping config tokens"); + break; + } + } + definitions=definitions->next; + } +} + static void accessLogCommon(AccessLogEntry * al) { Index: squid/src/cache_cf.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cache_cf.c,v retrieving revision 1.41.4.3 retrieving revision 1.41.4.4 diff -u -r1.41.4.3 -r1.41.4.4 --- squid/src/cache_cf.c 21 Apr 2002 19:36:46 -0000 1.41.4.3 +++ squid/src/cache_cf.c 26 Aug 2002 19:32:41 -0000 1.41.4.4 @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.c,v 1.41.4.3 2002/04/21 19:36:46 kinkie Exp $ + * $Id: cache_cf.c,v 1.41.4.4 2002/08/26 19:32:41 kinkie Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -2523,7 +2523,7 @@ static void dump_logformat_def(StoreEntry * entry, const char *name, logformat * definitions) { -#warning "TODO: implement this" + accessLogDumpLogFormat(entry,name,definitions); } static void Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.48.4.2 retrieving revision 1.48.4.3 diff -u -r1.48.4.2 -r1.48.4.3 --- squid/src/protos.h 9 Apr 2002 21:57:43 -0000 1.48.4.2 +++ squid/src/protos.h 26 Aug 2002 19:32:41 -0000 1.48.4.3 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.48.4.2 2002/04/09 21:57:43 kinkie Exp $ + * $Id: protos.h,v 1.48.4.3 2002/08/26 19:32:41 kinkie Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -40,6 +40,7 @@ extern void accessLogInit(void); extern const char *accessLogTime(time_t); extern void accessLogParseLogFormat (logformat_token **fmt, char *def); +extern void accessLogDumpLogFormat (StoreEntry *entry, const char *name, logformat * definitions); extern void hierarchyNote(HierarchyLogEntry *, hier_code, const char *); #if FORW_VIA_DB extern void fvdbCountVia(const char *key);