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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors