]> git.ipfire.org Git - thirdparty/squid.git/blob - src/LogTags.cc
C++11: Remove GnuRegex and all -lregex related code
[thirdparty/squid.git] / src / LogTags.cc
1 /*
2 * Copyright (C) 1996-2016 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_SWAPFAIL_MISS",
25 "TCP_NEGATIVE_HIT",
26 "TCP_MEM_HIT",
27 "TCP_DENIED",
28 "TCP_DENIED_REPLY",
29 "TCP_OFFLINE_HIT",
30 "TCP_REDIRECT",
31 "TCP_TUNNEL",
32 "UDP_HIT",
33 "UDP_MISS",
34 "UDP_DENIED",
35 "UDP_INVALID",
36 "UDP_MISS_NOFETCH",
37 "ICP_QUERY",
38 "TYPE_MAX"
39 };
40
41 /*
42 * This method is documented in http://wiki.squid-cache.org/SquidFaq/SquidLogs#Squid_result_codes
43 * Please keep the wiki up to date
44 */
45 const char *
46 LogTags::c_str() const
47 {
48 static char buf[1024];
49 *buf = 0;
50 int pos = 0;
51
52 // source tags
53 if (oldType && oldType < LOG_TYPE_MAX)
54 pos += snprintf(buf, sizeof(buf), "%s",Str_[oldType]);
55 else
56 pos += snprintf(buf, sizeof(buf), "NONE");
57
58 if (err.ignored)
59 pos += snprintf(buf+pos,sizeof(buf)-pos, "_IGNORED");
60
61 // error tags
62 if (err.timedout)
63 pos += snprintf(buf+pos,sizeof(buf)-pos, "_TIMEDOUT");
64 if (err.aborted)
65 pos += snprintf(buf+pos,sizeof(buf)-pos, "_ABORTED");
66
67 return buf;
68 }
69
70 bool
71 LogTags::isTcpHit() const
72 {
73 return
74 (oldType == LOG_TCP_HIT) ||
75 (oldType == LOG_TCP_IMS_HIT) ||
76 (oldType == LOG_TCP_REFRESH_FAIL_OLD) ||
77 (oldType == LOG_TCP_REFRESH_UNMODIFIED) ||
78 (oldType == LOG_TCP_NEGATIVE_HIT) ||
79 (oldType == LOG_TCP_MEM_HIT) ||
80 (oldType == LOG_TCP_OFFLINE_HIT);
81 }
82