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