]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/store_log.cc
4 static char *storeLogTags
[] =
12 static int storelog_fd
= -1;
15 storeLog(int tag
, const StoreEntry
* e
)
17 LOCAL_ARRAY(char, logmsg
, MAX_URL
<< 1);
18 MemObject
*mem
= e
->mem_obj
;
24 if (mem
->log_url
== NULL
) {
25 debug(20, 1) ("storeLog: NULL log_url for %s\n", mem
->url
);
26 storeMemObjectDump(mem
);
27 mem
->log_url
= xstrdup(mem
->url
);
30 snprintf(logmsg
, MAX_URL
<< 1, "%9d.%03d %-7s %08X %4d %9d %9d %9d %s %d/%d %s %s\n",
31 (int) current_time
.tv_sec
,
32 (int) current_time
.tv_usec
/ 1000,
37 (int) reply
->last_modified
,
39 strBuf(reply
->content_type
) ? strBuf(reply
->content_type
) : "unknown",
40 reply
->content_length
,
41 (int) (mem
->inmem_hi
- mem
->reply
->hdr_sz
),
42 RequestMethodStr
[mem
->method
],
44 file_write(storelog_fd
,
58 LOCAL_ARRAY(char, from
, MAXPATHLEN
);
59 LOCAL_ARRAY(char, to
, MAXPATHLEN
);
64 if (storelog_fd
> -1) {
65 file_close(storelog_fd
);
68 if ((fname
= Config
.Log
.store
) == NULL
)
70 if (strcmp(fname
, "none") == 0)
73 if (stat(fname
, &sb
) == 0)
74 if (S_ISREG(sb
.st_mode
) == 0)
78 debug(20, 1) ("storeLogRotate: Rotating.\n");
80 /* Rotate numbers 0 through N up one */
81 for (i
= Config
.Log
.rotateNumber
; i
> 1;) {
83 snprintf(from
, MAXPATHLEN
, "%s.%d", fname
, i
- 1);
84 snprintf(to
, MAXPATHLEN
, "%s.%d", fname
, i
);
87 /* Rotate the current log to .0 */
88 if (Config
.Log
.rotateNumber
> 0) {
89 snprintf(to
, MAXPATHLEN
, "%s.%d", fname
, 0);
92 storelog_fd
= file_open(fname
, O_WRONLY
| O_CREAT
, NULL
, NULL
, NULL
);
93 if (storelog_fd
< 0) {
94 debug(50, 0) ("storeLogRotate: %s: %s\n", fname
, xstrerror());
95 debug(20, 1) ("Store logging disabled\n");
102 if (storelog_fd
>= 0)
103 file_close(storelog_fd
);
109 if (strcmp(Config
.Log
.store
, "none") == 0)
112 storelog_fd
= file_open(Config
.Log
.store
,
118 debug(20, 1) ("Store logging disabled\n");