void storeLogOpen(void) { if (strcmp(Config.Log.store, "none") == 0) { debug(20, 1) ("Store logging disabled\n"); return; } storelog = logfileOpen(Config.Log.store, 0, 1); }
void refererOpenLog(void) { #if USE_REFERER_LOG assert(NULL == refererlog); if (!Config.Log.referer || (0 == strcmp(Config.Log.referer, "none"))) { debug(40, 1) ("Referer logging is disabled.\n"); return; } refererlog = logfileOpen(Config.Log.referer, 0, 1); #endif }
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); }