]> git.ipfire.org Git - thirdparty/squid.git/blob - src/LogTags.cc
Docs: Copyright updates for 2018 (#114)
[thirdparty/squid.git] / src / LogTags.cc
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 "LogTags.h"
11
12 // old deprecated tag strings
13 const char * LogTags::Str_[] = {
14 "TAG_NONE",
15 "TCP_HIT",
16 "TCP_MISS",
17 "TCP_REFRESH_UNMODIFIED",
18 "TCP_REFRESH_FAIL_OLD",
19 "TCP_REFRESH_FAIL_ERR",
20 "TCP_REFRESH_MODIFIED",
21 "TCP_REFRESH",
22 "TCP_CLIENT_REFRESH_MISS",
23 "TCP_IMS_HIT",
24 "TCP_INM_HIT",
25 "TCP_SWAPFAIL_MISS",
26 "TCP_NEGATIVE_HIT",
27 "TCP_MEM_HIT",
28 "TCP_DENIED",
29 "TCP_DENIED_REPLY",
30 "TCP_OFFLINE_HIT",
31 "TCP_REDIRECT",
32 "TCP_TUNNEL",
33 "UDP_HIT",
34 "UDP_MISS",
35 "UDP_DENIED",
36 "UDP_INVALID",
37 "UDP_MISS_NOFETCH",
38 "ICP_QUERY",
39 "TYPE_MAX"
40 };
41
42 /*
43 * This method is documented in http://wiki.squid-cache.org/SquidFaq/SquidLogs#Squid_result_codes
44 * Please keep the wiki up to date
45 */
46 const char *
47 LogTags::c_str() const
48 {
49 static char buf[1024];
50 *buf = 0;
51 int pos = 0;
52
53 // source tags
54 if (oldType && oldType < LOG_TYPE_MAX)
55 pos += snprintf(buf, sizeof(buf), "%s",Str_[oldType]);
56 else
57 pos += snprintf(buf, sizeof(buf), "NONE");
58
59 if (err.ignored)
60 pos += snprintf(buf+pos,sizeof(buf)-pos, "_IGNORED");
61
62 // error tags
63 if (err.timedout)
64 pos += snprintf(buf+pos,sizeof(buf)-pos, "_TIMEDOUT");
65 if (err.aborted)
66 pos += snprintf(buf+pos,sizeof(buf)-pos, "_ABORTED");
67
68 return buf;
69 }
70
71 bool
72 LogTags::isTcpHit() const
73 {
74 return
75 (oldType == LOG_TCP_HIT) ||
76 (oldType == LOG_TCP_IMS_HIT) ||
77 (oldType == LOG_TCP_INM_HIT) ||
78 (oldType == LOG_TCP_REFRESH_FAIL_OLD) ||
79 (oldType == LOG_TCP_REFRESH_UNMODIFIED) ||
80 (oldType == LOG_TCP_NEGATIVE_HIT) ||
81 (oldType == LOG_TCP_MEM_HIT) ||
82 (oldType == LOG_TCP_OFFLINE_HIT);
83 }
84