]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/store_log.cc
2 * $Id: store_log.cc,v 1.37 2008/01/20 08:54:28 amosjeffries Exp $
4 * DEBUG: section 20 Storage Manager Logging Functions
5 * AUTHOR: Duane Wessels
7 * SQUID Web Proxy Cache http://www.squid-cache.org/
8 * ----------------------------------------------------------
10 * Squid is the result of efforts by numerous individuals from
11 * the Internet community; see the CONTRIBUTORS file for full
12 * details. Many organizations have provided support for Squid's
13 * development; see the SPONSORS file for full details. Squid is
14 * Copyrighted (C) 2001 by the Regents of the University of
15 * California; see the COPYRIGHT file for full details. Squid
16 * incorporates software developed and/or copyrighted by other
17 * sources; see the CREDITS file for full details.
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
37 #include "MemObject.h"
38 #include "HttpReply.h"
39 #include "CacheManager.h"
40 #include "SquidTime.h"
42 static const char *storeLogTags
[] =
51 static int storeLogTagsCounts
[STORE_LOG_SWAPOUTFAIL
+1];
52 static OBJH storeLogTagsHist
;
54 static Logfile
*storelog
= NULL
;
57 storeLog(int tag
, const StoreEntry
* e
)
59 MemObject
*mem
= e
->mem_obj
;
60 HttpReply
const *reply
;
65 storeLogTagsCounts
[tag
]++;
67 if (mem
->log_url
== NULL
) {
68 debugs(20, 1, "storeLog: NULL log_url for " << mem
->url
);
70 mem
->log_url
= xstrdup(mem
->url
);
73 reply
= e
->getReply();
75 * XXX Ok, where should we print the dir number here?
76 * Because if we print it before the swap file number, it'll break
77 * the existing log format.
79 logfilePrintf(storelog
, "%9d.%03d %-7s %02d %08X %s %4d %9d %9d %9d %s %"PRId64
"/%"PRId64
" %s %s\n",
80 (int) current_time
.tv_sec
,
81 (int) current_time
.tv_usec
/ 1000,
88 (int) reply
->last_modified
,
90 reply
->content_type
.size() ? reply
->content_type
.buf() : "unknown",
91 reply
->content_length
,
93 RequestMethodStr(mem
->method
),
96 /* no mem object. Most RELEASE cases */
97 logfilePrintf(storelog
, "%9d.%03d %-7s %02d %08X %s ? ? ? ? ?/? ?/? ? ?\n",
98 (int) current_time
.tv_sec
,
99 (int) current_time
.tv_usec
/ 1000,
110 if (NULL
== storelog
)
113 logfileRotate(storelog
);
119 if (NULL
== storelog
)
122 logfileClose(storelog
);
130 if (strcmp(Config
.Log
.store
, "none") == 0) {
131 debugs(20, 1, "Store logging disabled");
135 storelog
= logfileOpen(Config
.Log
.store
, 0, 1);
139 storeLogRegisterWithCacheManager(CacheManager
& manager
)
141 manager
.registerAction("store_log_tags",
142 "Histogram of store.log tags",
143 storeLogTagsHist
, 0, 1);
147 storeLogTagsHist(StoreEntry
*e
)
150 for (tag
= 0; tag
<= STORE_LOG_SWAPOUTFAIL
; tag
++) {
151 storeAppendPrintf(e
, "%s %d\n",
153 storeLogTagsCounts
[tag
]);