LogTags.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9#include "squid.h"
10#include "debug/Stream.h"
11#include "LogTags.h"
12
13void
15{
16 ignored = ignored || other.ignored;
17 timedout = timedout || other.timedout;
18 aborted = aborted || other.aborted;
19}
20
21/* LogTags */
22
23// old deprecated tag strings
24const char * LogTags::Str_[] = {
25 "TAG_NONE",
26 "TCP_HIT",
27 "TCP_MISS",
28 "TCP_REFRESH_UNMODIFIED",
29 "TCP_REFRESH_FAIL_OLD",
30 "TCP_REFRESH_FAIL_ERR",
31 "TCP_REFRESH_MODIFIED",
32 "TCP_REFRESH",
33 "TCP_CLIENT_REFRESH_MISS",
34 "TCP_IMS_HIT",
35 "TCP_INM_HIT",
36 "TCP_SWAPFAIL_MISS",
37 "TCP_NEGATIVE_HIT",
38 "TCP_MEM_HIT",
39 "TCP_DENIED",
40 "TCP_DENIED_REPLY",
41 "TCP_OFFLINE_HIT",
42 "TCP_REDIRECT",
43 "TCP_TUNNEL",
44 "UDP_HIT",
45 "UDP_MISS",
46 "UDP_DENIED",
47 "UDP_INVALID",
48 "UDP_MISS_NOFETCH",
49 "ICP_QUERY",
50 "TYPE_MAX"
51};
52
53void
55{
57 debugs(83, 7, Str_[oldType] << " to " << Str_[t]);
58 oldType = t;
59}
60
61/*
62 * This method is documented in https://wiki.squid-cache.org/SquidFaq/SquidLogs#squid-result-codes
63 * Please keep the wiki up to date
64 */
65const char *
67{
68 static char buf[1024];
69 *buf = 0;
70 int pos = 0;
71
72 // source tags
73 const int protoLen = 3;
74 if (oldType && oldType < LOG_TYPE_MAX) {
75 assert(Str_[oldType][protoLen] == '_');
76 snprintf(buf, protoLen + 1, "%s", Str_[oldType]);
77 pos += protoLen;
78 }
79 else
80 pos += snprintf(buf, sizeof(buf), "NONE");
81
83 pos += snprintf(buf + pos, sizeof(buf) - pos, "_CF");
84
85 const char *tag = Str_[oldType] + protoLen;
86 pos += snprintf(buf + pos, sizeof(buf) - pos, "%s", tag);
87
88 if (err.ignored)
89 pos += snprintf(buf+pos,sizeof(buf)-pos, "_IGNORED");
90
91 // error tags
92 if (err.timedout)
93 pos += snprintf(buf+pos,sizeof(buf)-pos, "_TIMEDOUT");
94 if (err.aborted)
95 pos += snprintf(buf+pos,sizeof(buf)-pos, "_ABORTED");
96
97 return buf;
98}
99
100bool
102{
103 return
104 (oldType == LOG_TCP_HIT) ||
112}
113
114const char *
116{
117 // see draft-ietf-httpbis-cache-header for the (quoted below) specs
118 switch (oldType) {
119 case LOG_TAG_NONE:
120 return nullptr;
121
122 case LOG_TCP_HIT:
123 case LOG_TCP_IMS_HIT:
124 case LOG_TCP_INM_HIT:
128 case LOG_TCP_MEM_HIT:
130 // We put LOG_TCP_REFRESH_UNMODIFIED and LOG_TCP_REFRESH_FAIL_OLD here
131 // because the specs probably classify master transactions where the
132 // client request did "go forward" but the to-client response was
133 // ultimately "obtained from the cache" as "hit" transactions.
134 return ";hit";
135
136 case LOG_TCP_MISS:
137#if USE_DELAY_POOLS
138 // do not lie until we get a better solution for bugs 1000, 2096
139 return nullptr;
140#else
141 // TODO: "distinguish between uri-miss and vary-miss"
142 return ";fwd=miss";
143#endif
144
146 case LOG_TCP_REFRESH:
147 return ";fwd=stale";
148
150 return ";fwd=request";
151
154 // Ignore "to be used when the implementation cannot distinguish between
155 // uri-miss and vary-miss" specs condition as being too restrictive,
156 // especially when there is no fwd=other or a more suitable parameter.
157 return ";fwd=miss";
158
159 case LOG_TCP_DENIED:
161 case LOG_TCP_REDIRECT:
162 // We served a Squid-generated response (with or without forwarding).
163 // The response itself should provide enough classification clues.
164 return nullptr;
165
166 case LOG_TCP_TUNNEL:
167 // could use fwd=bypass, but the CONNECT request was not really bypassed
168 return nullptr;
169
170 case LOG_UDP_HIT:
171 case LOG_UDP_MISS:
172 case LOG_UDP_DENIED:
173 case LOG_UDP_INVALID:
175 case LOG_ICP_QUERY:
176 // do not bother classifying these non-HTTP outcomes for now
177 return nullptr;
178
179 case LOG_TYPE_MAX:
180 // should not happen
181 return nullptr;
182 }
183
184 // should not happen
185 return nullptr;
186}
187
LogTags_ot
Definition: LogTags.h:37
@ LOG_TCP_REFRESH_FAIL_ERR
Definition: LogTags.h:43
@ LOG_TCP_DENIED
Definition: LogTags.h:52
@ LOG_TCP_REFRESH
Definition: LogTags.h:45
@ LOG_UDP_MISS_NOFETCH
Definition: LogTags.h:61
@ LOG_TCP_NEGATIVE_HIT
Definition: LogTags.h:50
@ LOG_TCP_REFRESH_MODIFIED
Definition: LogTags.h:44
@ LOG_TCP_REDIRECT
Definition: LogTags.h:55
@ LOG_TCP_OFFLINE_HIT
Definition: LogTags.h:54
@ LOG_TCP_HIT
Definition: LogTags.h:39
@ LOG_TCP_REFRESH_FAIL_OLD
Definition: LogTags.h:42
@ LOG_UDP_DENIED
Definition: LogTags.h:59
@ LOG_TCP_MISS
Definition: LogTags.h:40
@ LOG_TCP_MEM_HIT
Definition: LogTags.h:51
@ LOG_TCP_IMS_HIT
Definition: LogTags.h:47
@ LOG_UDP_HIT
Definition: LogTags.h:57
@ LOG_TCP_TUNNEL
an attempt to establish a bidirectional TCP tunnel
Definition: LogTags.h:56
@ LOG_ICP_QUERY
Definition: LogTags.h:62
@ LOG_TAG_NONE
Definition: LogTags.h:38
@ LOG_TYPE_MAX
Definition: LogTags.h:63
@ LOG_TCP_REFRESH_UNMODIFIED
Definition: LogTags.h:41
@ LOG_TCP_DENIED_REPLY
Definition: LogTags.h:53
@ LOG_TCP_SWAPFAIL_MISS
Definition: LogTags.h:49
@ LOG_UDP_MISS
Definition: LogTags.h:58
@ LOG_UDP_INVALID
Definition: LogTags.h:60
@ LOG_TCP_CLIENT_REFRESH_MISS
Definition: LogTags.h:46
@ LOG_TCP_INM_HIT
Definition: LogTags.h:48
#define assert(EX)
Definition: assert.h:17
bool collapsed() const
whether at least one request was collapsed
bool aborted
_ABORTED: other abnormal termination (e.g., I/O error)
Definition: LogTags.h:26
void update(const LogTagsErrors &other)
Definition: LogTags.cc:14
bool timedout
_TIMEDOUT: terminated due to a lifetime or I/O timeout
Definition: LogTags.h:25
bool ignored
_IGNORED: the response was not used for anything
Definition: LogTags.h:24
const char * c_str() const
compute the status access.log field
Definition: LogTags.cc:66
const char * cacheStatusSource() const
Definition: LogTags.cc:115
void update(const LogTags_ot t)
Definition: LogTags.cc:54
LogTagsErrors err
various problems augmenting the primary log tag
Definition: LogTags.h:84
static const char * Str_[]
list of string representations for LogTags_ot
Definition: LogTags.h:88
CollapsingHistory collapsingHistory
controls CF tag presence
Definition: LogTags.h:95
LogTags_ot oldType
a set of client protocol, cache use, and other transaction outcome tags
Definition: LogTags.h:93
bool isTcpHit() const
determine if the log tag code indicates a cache HIT
Definition: LogTags.cc:101
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:194

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors