void storeLog(int tag, const StoreEntry * e) { MemObject *mem = e->mem_obj; HttpReply *reply; if (NULL == storelog) return; #if UNUSED_CODE if (EBIT_TEST(e->flags, ENTRY_DONT_LOG)) return; #endif if (mem != NULL) { if (mem->log_url == NULL) { debug(20, 1) ("storeLog: NULL log_url for %s\n", mem->url); storeMemObjectDump(mem); mem->log_url = xstrdup(mem->url); } reply = mem->reply; /* * XXX Ok, where should we print the dir number here? * Because if we print it before the swap file number, it'll break * the existing log format. */ logfilePrintf(storelog, "%9d.%03d %-7s %02d %08X %s %4d %9d %9d %9d %s %d/%d %s %s\n", (int) current_time.tv_sec, (int) current_time.tv_usec / 1000, storeLogTags[tag], e->swap_dirn, e->swap_filen, storeKeyText(e->hash.key), reply->sline.status, (int) reply->date, (int) reply->last_modified, (int) reply->expires, strLen(reply->content_type) ? strBuf(reply->content_type) : "unknown", reply->content_length, (int) (mem->inmem_hi - mem->reply->hdr_sz), RequestMethodStr[mem->method], mem->log_url); } else { /* no mem object. Most RELEASE cases */ logfilePrintf(storelog, "%9d.%03d %-7s %02d %08X %s ? ? ? ? ?/? ?/? ? ?\n", (int) current_time.tv_sec, (int) current_time.tv_usec / 1000, storeLogTags[tag], e->swap_dirn, e->swap_filen, storeKeyText(e->hash.key)); } }
void storeLog(int tag, const StoreEntry * e) { MemObject *mem = e->mem_obj; HttpReply *reply; if (NULL == storelog) return; #if UNUSED_CODE if (EBIT_TEST(e->flags, ENTRY_DONT_LOG)) return; #endif if (mem != NULL) { reply = mem->reply; /* * XXX Ok, where should we print the dir number here? * Because if we print it before the swap file number, it'll break * the existing log format. */ logfileLineStart(storelog); logfilePrintf(storelog, "%9ld.%03d %-7s %02d %08X %s %4d %9ld %9ld %9ld %s %" PRINTF_OFF_T "/%" PRINTF_OFF_T " %s %s\n", (long int) current_time.tv_sec, (int) current_time.tv_usec / 1000, storeLogTags[tag], e->swap_dirn, e->swap_filen, storeKeyText(e->hash.key), reply->sline.status, (long int) reply->date, (long int) reply->last_modified, (long int) reply->expires, strLen(reply->content_type) ? strBuf(reply->content_type) : "unknown", reply->content_length, mem->inmem_hi - mem->reply->hdr_sz, RequestMethods[mem->method].str, rfc1738_escape_unescaped(mem->url)); logfileLineEnd(storelog); } else { /* no mem object. Most RELEASE cases */ logfileLineStart(storelog); logfilePrintf(storelog, "%9ld.%03d %-7s %02d %08X %s ? ? ? ? ?/? ?/? ? ?\n", (long int) current_time.tv_sec, (int) current_time.tv_usec / 1000, storeLogTags[tag], e->swap_dirn, e->swap_filen, storeKeyText(e->hash.key)); logfileLineEnd(storelog); } }
static void netdbSaveState(void *foo) { Logfile *lf; netdbEntry *n; net_db_name *x; struct timeval start = current_time; int count = 0; if (strcmp(Config.netdbFilename, "none") == 0) return; /* * This was nicer when we were using stdio, but thanks to * Solaris bugs, its a bad idea. fopen can fail if more than * 256 FDs are open. */ /* * unlink() is here because there is currently no way to make * logfileOpen() use O_TRUNC. */ unlink(Config.netdbFilename); lf = logfileOpen(Config.netdbFilename, 4096, 0); if (NULL == lf) { debug(50, 1) ("netdbSaveState: %s: %s\n", Config.netdbFilename, xstrerror()); return; } hash_first(addr_table); while ((n = (netdbEntry *) hash_next(addr_table))) { if (n->pings_recv == 0) continue; logfilePrintf(lf, "%s %d %d %10.5f %10.5f %d %d", n->network, n->pings_sent, n->pings_recv, n->hops, n->rtt, (int) n->next_ping_time, (int) n->last_use_time); for (x = n->hosts; x; x = x->next) logfilePrintf(lf, " %s", hashKeyStr(&x->hash)); logfilePrintf(lf, "\n"); count++; #undef RBUF_SZ } logfileClose(lf); getCurrentTime(); debug(38, 1) ("NETDB state saved; %d entries, %d msec\n", count, tvSubMsec(start, current_time)); eventAddIsh("netdbSaveState", netdbSaveState, NULL, 3600.0, 1); }
void logReferer(const char *client, const char *referer, const char *uri) { #if USE_REFERER_LOG if (NULL == refererlog) return; logfilePrintf(refererlog, "%9d.%03d %s %s %s\n", (int) current_time.tv_sec, (int) current_time.tv_usec / 1000, client, referer, uri ? uri : "-"); #endif }