LogTags.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 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 
CollapsingHistory collapsingHistory
controls CF tag presence
Definition: LogTags.h:86
#define assert(EX)
Definition: assert.h:17
bool timedout
_TIMEDOUT: terminated due to a lifetime or I/O timeout
Definition: LogTags.h:73
bool collapsed() const
whether at least one request was collapsed
bool isTcpHit() const
determine if the log tag code indicates a cache HIT
Definition: LogTags.cc:91
bool ignored
_IGNORED: the response was not used for anything
Definition: LogTags.h:72
const char * c_str() const
compute the status access.log field
Definition: LogTags.cc:56
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:124
LogTags_ot
Definition: LogTags.h:22
void update(const LogTags_ot t)
Definition: LogTags.cc:44
void const char * buf
Definition: stub_helper.cc:16
LogTags_ot oldType
a set of client protocol, cache use, and other transaction outcome tags
Definition: LogTags.h:84
class LogTags::Errors err
static const char * Str_[]
list of string representations for LogTags_ot
Definition: LogTags.h:79
bool aborted
_ABORTED: other abnormal termination (e.g., I/O error)
Definition: LogTags.h:74

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors