]> git.ipfire.org Git - thirdparty/squid.git/blob - src/LogTags.h
Bug 5148: Log %Ss of failed tunnels as TCP_TUNNEL (#1354)
[thirdparty/squid.git] / src / LogTags.h
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 #ifndef SQUID_SRC_LOGTAGS_H
10 #define SQUID_SRC_LOGTAGS_H
11
12 #include "CollapsingHistory.h"
13
14 /// Things that may happen to a transaction while it is being
15 /// processed according to its LOG_* category. Logged as _SUFFIX(es).
16 /// Unlike LOG_* categories, these flags may not be mutually exclusive.
17 class LogTagsErrors
18 {
19 public:
20 /// Update each of this object flags to "set" if the corresponding
21 /// flag of the given object is set
22 void update(const LogTagsErrors &other);
23
24 bool ignored = false; ///< _IGNORED: the response was not used for anything
25 bool timedout = false; ///< _TIMEDOUT: terminated due to a lifetime or I/O timeout
26 bool aborted = false; ///< _ABORTED: other abnormal termination (e.g., I/O error)
27 };
28
29 /** Squid transaction result code/tag set.
30 *
31 * These codes indicate how the request was received
32 * and some details about its processing pathway.
33 *
34 * see also http://wiki.squid-cache.org/SquidFaq/SquidLogs#Squid_result_codes
35 * for details on particular components.
36 */
37 typedef enum {
38 LOG_TAG_NONE = 0,
39 LOG_TCP_HIT,
40 LOG_TCP_MISS,
41 LOG_TCP_REFRESH_UNMODIFIED, // refresh from origin revalidated existing entry
42 LOG_TCP_REFRESH_FAIL_OLD, // refresh from origin failed, stale reply sent
43 LOG_TCP_REFRESH_FAIL_ERR, // refresh from origin failed, error forwarded
44 LOG_TCP_REFRESH_MODIFIED, // refresh from origin replaced existing entry
45 LOG_TCP_REFRESH, // refresh from origin started, but still pending
46 LOG_TCP_CLIENT_REFRESH_MISS,
47 LOG_TCP_IMS_HIT,
48 LOG_TCP_INM_HIT,
49 LOG_TCP_SWAPFAIL_MISS,
50 LOG_TCP_NEGATIVE_HIT,
51 LOG_TCP_MEM_HIT,
52 LOG_TCP_DENIED,
53 LOG_TCP_DENIED_REPLY,
54 LOG_TCP_OFFLINE_HIT,
55 LOG_TCP_REDIRECT,
56 LOG_TCP_TUNNEL, ///< an attempt to establish a bidirectional TCP tunnel
57 LOG_UDP_HIT,
58 LOG_UDP_MISS,
59 LOG_UDP_DENIED,
60 LOG_UDP_INVALID,
61 LOG_UDP_MISS_NOFETCH,
62 LOG_ICP_QUERY,
63 LOG_TYPE_MAX
64 } LogTags_ot;
65
66 class LogTags
67 {
68 public:
69 LogTags() = default;
70 explicit LogTags(const LogTags_ot t) { update(t); }
71
72 void update(const LogTags_ot t);
73
74 /// compute the status access.log field
75 const char *c_str() const;
76
77 /// determine if the log tag code indicates a cache HIT
78 bool isTcpHit() const;
79
80 /// \returns Cache-Status "hit" or "fwd=..." parameter (or nil)
81 const char *cacheStatusSource() const;
82
83 /// various problems augmenting the primary log tag
84 LogTagsErrors err;
85
86 private:
87 /// list of string representations for LogTags_ot
88 static const char *Str_[];
89
90 public: // XXX: only until client_db.cc stats are redesigned.
91
92 /// a set of client protocol, cache use, and other transaction outcome tags
93 LogTags_ot oldType = LOG_TAG_NONE;
94 /// controls CF tag presence
95 CollapsingHistory collapsingHistory;
96 };
97
98 /// iterator for LogTags_ot enumeration
99 inline LogTags_ot &operator++ (LogTags_ot &aLogType)
100 {
101 int tmp = (int)aLogType;
102 aLogType = (LogTags_ot)(++tmp);
103 return aLogType;
104 }
105
106 #endif
107