This directive controls cache.log printing of important messages.
Rationale: In any given deployment environment, many of the cache.log
messages that Squid logs by default are noise. Some of them should
probably never be logged by default, but some are useful or even
critical in certain other environments. No single approach to logging is
going to satisfy all needs. The existing debug_options directive
operates on large message groups and is not suitable for controlling
individual critical or important messages.
The current implementation uses hard-coded manually-assigned opaque
message IDs. We have also experimented with an automated generation of
message IDs, including meaningful IDs and compiler-generated IDs created
by various advanced C++ preprocessing and template tricks. All of the
automation considered (and some partially implemented) were rejected
for being overall worse than the current manual approach.
TODO: The usefulness of ID ranges will diminish with time. We could
support named (hard-coded) sets of message IDs (e.g., "startup",
"shutdown", and "configuration"). However, sets make it easier to
accidentally suppress an important new message during an upgrade.
DEFAULT_ERROR_DIR = $(datadir)/errors
EXTRA_DIST = \
+ debug-messages.dox \
debug-sections.txt
--- /dev/null
+/*
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+/**
+\page ControlledCacheLogMessages Message IDs and gists for cache_log_message
+\verbatim
+ID Message gist
+== ============
+2 Preparing for shutdown after ... requests
+3 Waiting ... seconds for active connections to finish
+4 Set Current Directory to ...
+5 Service Name: ...
+6 Process ID ...
+7 Process Roles: ...
+8 With ... file descriptors available
+9 Shutting down...
+10 Squid Cache (Version ...): Exiting normally.
+11 Adaptation support is ...
+12 Shutdown: Basic authentication.
+13 Accepting ... connections at ...
+14 Closing HTTP(S) port ...
+15 Adding nameserver ... from squid.conf
+16 DNS IPv6 socket created at ..., FD ...
+17 Open FD ... ...
+18 Loading cache_dir # ... from ...
+19 helperOpenServers: Starting .../ ... ' ...' processes
+20 helperOpenServers: No ' ...' processes needed.
+21 HTCP Disabled.
+22 Removing ...
+23 Created ...
+24 Initializing IP Cache...
+25 Squid plugin modules loaded: ...
+26 Logfile: opening log ...
+27 Logfile: closing log ...
+28 Finished loading MIME types and icons.
+29 Configuring ... .../ .../ ...
+30 storeLateRelease: released ... objects
+31 Swap maxSize ... KB, estimated ... objects
+32 Target number of buckets: ...
+33 Using ... Store buckets
+34 Max Mem size: ...
+35 Max Swap size: ... KB
+36 Using Least Load store dir selection
+37 Not currently OK to rewrite swap log.
+38 storeDirWriteCleanLogs: Operation aborted.
+39 storeDirWriteCleanLogs: Starting...
+40 Finished. Wrote ... entries.
+41 Took ... seconds (... entries/sec).
+42 Store logging disabled
+43 Completed Validation Procedure ...Validated ... Entries ...store_swap_size = ... KB
+46 Finished rebuilding storage from disk. ... Entries scanned ... Invalid entries ... With invalid flags ... Objects loaded ... Objects expired ... Objects canceled ... Duplicate URLs purged ... Swapfile clashes avoided ...Took ... seconds ( ... objects/sec).
+56 Beginning Validation Procedure
+57 Indexing cache entries: ...
+58 ALE missing ...
+59 Shutdown: Digest authentication.
+60 Shutdown: Negotiate authentication.
+61 Shutdown: NTLM authentication.
+63 Resuming indexing cache_dir # ... from ...
+64 DNS IPv4 socket created at ..., FD ...
+\endverbatim
+*/
return $problems
}
+# extract IDs and gists of cache_log_message debugs() in the given source file
+collectDebugMessagesFrom ()
+{
+ source="$1"
+ destination="doc/debug-messages.tmp"
+
+ # Merge multi-line debugs() into one-liners and remove '//...' comments.
+ awk 'BEGIN { found=0; dbgLine=""; } {
+ if ($0 ~ /[ \t]debugs[ \t]*\(/)
+ found = 1;
+ if (found) {
+ commented = match($0, /\);[ \t]*\/\//);
+ if (commented)
+ $0 = substr($0, 1, RSTART+1);
+ dbgLine = dbgLine $0;
+ }
+ if ($0 ~ /\);/) {
+ if (found) {
+ found = 0;
+ print dbgLine;
+ dbgLine = "";
+ }
+ }
+ }' $source > doc/debug-messages.tmp2
+
+ # sed expressions:
+ # - replace debugs() prefix with the message ID contained in it
+ # - remove simple parenthesized non-"string" items like (a ? b : c)
+ # - replace any remaining non-"string" items with ...
+ # - remove quotes around "strings"
+ # - remove excessive whitespace
+ # - remove debugs() statement termination sugar
+ grep -o -E '\bdebugs[^,]*,\s*(Critical|Important)[(][0-9]+.*' doc/debug-messages.tmp2 | \
+ sed -r \
+ -e 's/.*?(Critical|Important)[(]([0-9]+)[)],\s*/\2 /' \
+ -e 's/<<\s*[(].*[)]\s*(<<|[)];)/<< ... \1/g' \
+ -e 's/<<\s*[^"]*/.../g' \
+ -e 's@([^\\])"@\1@g' \
+ -e 's/\s\s*/ /g' \
+ -e 's/[)];$//g' \
+ >> $destination
+
+ rm -f doc/debug-messages.tmp2
+}
+
+# make doc/debug-messages.dox from aggregate collectDebugMessagesFrom results
+processDebugMessages ()
+{
+ source="doc/debug-messages.tmp"
+ destination="doc/debug-messages.dox"
+
+ if test '!' -s "$source"; then
+ echo "ERROR: Failed to find debugs() message IDs"
+ return 1;
+ fi
+
+ repeatedIds=`awk '{print $1}' $source | sort -n | uniq -d`
+ if test "x$repeatedIds" != "x"; then
+ echo "ERROR: Repeated debugs() message IDs:"
+ echo "$repeatedIds"
+ echo ""
+ return 1;
+ fi
+
+ repeatedGists=`awk '{$1=""; print substr($0,2)}' $source | sort | uniq -d`
+ if test "x$repeatedGists" != "x"; then
+ echo "ERROR: Repeated debugs() message gists:"
+ echo "$repeatedGists"
+ echo ""
+ return 1;
+ fi
+
+ cat scripts/boilerplate.h > $destination
+ printf '/**\n' >> $destination
+ printf '\\page ControlledCacheLogMessages Message IDs and gists for cache_log_message\n' >> $destination
+ printf '\\verbatim\n' >> $destination
+ printf 'ID Message gist\n' >> $destination
+ printf '== ============\n' >> $destination
+ sort -n < $source >> $destination
+ printf '\\endverbatim\n' >> $destination
+ printf '*/\n' >> $destination
+
+ rm -f $source
+}
+
+# make doc/debug-sections.txt from aggregated by srcFormat extracts
+processDebugSections ()
+{
+ destination="doc/debug-sections.txt"
+
+ sort -u < doc/debug-sections.tmp | sort -n > doc/debug-sections.tmp2
+ cat scripts/boilerplate.h > $destination
+ echo "" >> $destination
+ cat doc/debug-sections.tmp2 >> $destination
+
+ rm -f doc/debug-sections.tmp*
+}
+
srcFormat ()
{
+ # remove stale temporary files that accumulate info extracted below
+ rm -f doc/debug-messages.tmp*
+ rm -f doc/debug-sections.tmp*
+
#
# Scan for incorrect use of #ifdef/#ifndef
#
echo "ERROR: ${FILENAME} contains unsafe use of sprintf()"
fi
+ collectDebugMessagesFrom ${FILENAME}
+
#
# DEBUG Section list maintenance
#
fi
done
+
+ run_ processDebugSections || return
+ run_ processDebugMessages || return
}
# Build XPROF types file from current sources
run_ checkMakeNamedErrorDetails || exit 1
# Run formatting
-echo "" >doc/debug-sections.tmp
srcFormat || exit 1
-sort -u <doc/debug-sections.tmp | sort -n >doc/debug-sections.tmp2
-cat scripts/boilerplate.h doc/debug-sections.tmp2 >doc/debug-sections.txt
-rm doc/debug-sections.tmp doc/debug-sections.tmp2
+
rm -f boilerplate_fix.sed
exit $SeenErrors
--- /dev/null
+/*
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+/* DEBUG: section 00 Debug Routines */
+
+#ifndef SQUID_DEBUG_MESSAGES_H
+#define SQUID_DEBUG_MESSAGES_H
+
+#include "Debug.h"
+#include "SquidConfig.h"
+
+#include <array>
+#include <limits>
+
+// XXX: Replace Debug class with namespace and use that namespace here.
+
+/// an identifier for messages supporting configuration via cache_log_message
+typedef size_t DebugMessageId;
+
+/// manages configurable aspects of a debugs() message
+class DebugMessage
+{
+public:
+ /// whether the logging of this message has been customized
+ bool configured() const { return id > 0; }
+
+ /// whether the default logging level of this message has been altered
+ bool levelled() const { return level >= 0; }
+
+ /// whether the number of logging attempts have been limited
+ bool limited() const { return limit < std::numeric_limits<decltype(limit)>::max(); }
+
+ /// \returns appropriate debugging level for the message
+ int currentLevel(const int defaultLevel) const {
+ if (configured()) {
+ if (count_++ < limit)
+ return level;
+ return (level <= DBG_IMPORTANT) ? 3 : 8;
+ }
+ return defaultLevel;
+ }
+
+ /// message identifier or, if the message has not been configured, zero
+ DebugMessageId id = 0;
+
+ /* all these configurable members are ignored unless configured() */
+
+ /// debugging level (i.e., the second debugs() parameter) or -1
+ int level = -1;
+
+ /// logging attempts beyond this limit are logged at the DBG_DATA level
+ uint64_t limit = std::numeric_limits<uint64_t>::max();
+
+private:
+ /// the total number of attempts to log this message if it was configured()
+ mutable uint64_t count_ = 0;
+};
+
+/// The maximum used DebugMessage::id plus 1. Increase as you add new IDs.
+constexpr DebugMessageId DebugMessageIdUpperBound = 65;
+
+/// a collection of DebugMessage objects (with fast access by message IDs)
+class DebugMessages
+{
+public:
+ /// configurable messages indexed by their IDs
+ typedef std::array<DebugMessage, DebugMessageIdUpperBound> Storage;
+ Storage messages;
+};
+
+// Using a template allows us to check message ID range at compile time.
+/// \returns configured debugging level for the given message or defaultLevel
+template <DebugMessageId id>
+inline int
+DebugMessageLevel(const int defaultLevel)
+{
+ static_assert(id > 0, "debugs() message ID must be positive");
+ static_assert(id < DebugMessageIdUpperBound, "debugs() message ID must be smaller than DebugMessageIdUpperBound");
+ if (const auto configured = Config.debugMessages)
+ return (configured->messages)[id].currentLevel(defaultLevel);
+ return defaultLevel;
+}
+
+/* convenience macros for calling DebugMessageLevel */
+#define Critical(id) DebugMessageLevel<id>(DBG_CRITICAL)
+#define Important(id) DebugMessageLevel<id>(DBG_IMPORTANT)
+#define Dbg(id, defaultLevel) DebugMessageLevel<id>(defaultLevel)
+
+#endif /* SQUID_DEBUG_MESSAGES_H */
+
#include "squid.h"
#include "base/File.h"
+#include "DebugMessages.h"
#include "fs_io.h"
#include "Instance.h"
#include "parser/Tokenizer.h"
if (ThePidFileToRemove.isEmpty()) // not the PidFilename()!
return; // nothing to do
- debugs(50, DBG_IMPORTANT, "Removing " << PidFileDescription(ThePidFileToRemove));
+ debugs(50, Important(22), "Removing " << PidFileDescription(ThePidFileToRemove));
const char *filename = ThePidFileToRemove.c_str(); // avoid complex operations inside enter_suid()
enter_suid();
safeunlink(filename, 0);
// our written PID (and decide that they are dealing with a corrupted PID file).
pidFile.synchronize();
- debugs(50, DBG_IMPORTANT, "Created " << TheFile);
+ debugs(50, Important(23), "Created " << TheFile);
}
#include "squid.h"
#include "Debug.h"
+#include "DebugMessages.h"
#include "LoadableModule.h"
#include "LoadableModules.h"
#include "wordlist.h"
int count = 0;
for (const wordlist *i = names; i; i = i->next, ++count)
LoadModule(i->key);
- debugs(1, DBG_IMPORTANT, "Squid plugin modules loaded: " << count);
+ debugs(1, Important(25), "Squid plugin modules loaded: " << count);
}
CpuAffinitySet.cc \
CpuAffinitySet.h \
Debug.h \
+ DebugMessages.h \
Downloader.cc \
Downloader.h \
ETag.cc \
#include "Debug.h"
#include "globals.h"
#include "Parsing.h"
+#include "sbuf/Stream.h"
/*
* These functions is the same as atoi/l/f, except that they check for errors
xatoui(const char *token, char eov)
{
int64_t input = xatoll(token, 10, eov);
- if (input < 0) {
- debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT), "ERROR: The input value '" << token << "' cannot be less than 0.");
- self_destruct();
- }
+ if (input < 0)
+ throw TextException(ToSBuf("the input value '", token, "' cannot be less than 0"), Here());
unsigned int ret = (unsigned int) input;
- if (input != static_cast<int64_t>(ret)) {
- debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT), "ERROR: The value '" << token << "' is larger than the type 'unsigned int'.");
- self_destruct();
- }
+ if (input != static_cast<int64_t>(ret))
+ throw TextException(ToSBuf("the value '", token, "' is larger than the type 'unsigned int'"), Here());
return ret;
}
return ret;
}
+uint64_t
+xatoull(const char *token, int base, char eov)
+{
+ const auto number = xatoll(token, base, eov);
+ if (number < 0)
+ throw TextException(ToSBuf("the input value '", token, "' cannot be less than 0"), Here());
+ return static_cast<uint64_t>(number);
+}
+
unsigned short
xatos(const char *token)
{
unsigned int xatoui(const char *token, char eov = '\0');
long xatol(const char *token);
int64_t xatoll(const char *token, int base, char eov = '\0');
+uint64_t xatoull(const char *token, int base, char eov = '\0');
unsigned short xatos(const char *token);
/**
class CachePeer;
class CustomLog;
class CpuAffinityMap;
+class DebugMessages;
class external_acl;
class HeaderManglers;
class RefreshPattern;
int connect_gap;
int connect_timeout;
} happyEyeballs;
+
+ DebugMessages *debugMessages; ///< cache_log_message
};
extern SquidConfig Config;
#include "client_side.h"
#include "comm/Connection.h"
#include "comm/forward.h"
+#include "DebugMessages.h"
#include "ExternalACLEntry.h"
#include "http/Stream.h"
#include "HttpReply.h"
return;
++count;
- debugs(28, DBG_IMPORTANT, "ALE missing " << msg);
+ debugs(28, Important(58), "ALE missing " << msg);
}
void
#include "adaptation/Service.h"
#include "adaptation/ServiceGroups.h"
#include "ConfigParser.h"
+#include "DebugMessages.h"
#include "globals.h"
#include "HttpReply.h"
#include "HttpRequest.h"
Adaptation::Config::Finalize(bool enabled)
{
Enabled = enabled;
- debugs(93, DBG_IMPORTANT, "Adaptation support is " << (Enabled ? "on" : "off."));
+ debugs(93, Important(11), "Adaptation support is " << (Enabled ? "on" : "off."));
FinalizeEach(AllServices(), "message adaptation services");
FinalizeEach(AllGroups(), "message adaptation service groups");
#include "auth/basic/Config.h"
#include "auth/basic/Scheme.h"
#include "Debug.h"
+#include "DebugMessages.h"
#include "helper.h"
Auth::Scheme::Pointer Auth::Basic::Scheme::_instance = NULL;
return;
_instance = NULL;
- debugs(29, DBG_CRITICAL, "Shutdown: Basic authentication.");
+ debugs(29, Critical(12), "Shutdown: Basic authentication.");
}
Auth::SchemeConfig *
#include "auth/digest/Config.h"
#include "auth/digest/Scheme.h"
#include "Debug.h"
+#include "DebugMessages.h"
#include "globals.h"
#include "helper.h"
authenticateDigestNonceShutdown();
_instance = NULL;
- debugs(29, DBG_CRITICAL, "Shutdown: Digest authentication.");
+ debugs(29, Critical(59), "Shutdown: Digest authentication.");
}
Auth::SchemeConfig *
#include "auth/negotiate/Config.h"
#include "auth/negotiate/Scheme.h"
#include "Debug.h"
+#include "DebugMessages.h"
#include "helper.h"
Auth::Scheme::Pointer Auth::Negotiate::Scheme::_instance = NULL;
return;
_instance = NULL;
- debugs(29, DBG_CRITICAL, "Shutdown: Negotiate authentication.");
+ debugs(29, Critical(60), "Shutdown: Negotiate authentication.");
}
Auth::SchemeConfig *
#include "auth/ntlm/Config.h"
#include "auth/ntlm/Scheme.h"
#include "Debug.h"
+#include "DebugMessages.h"
#include "helper.h"
Auth::Scheme::Pointer Auth::Ntlm::Scheme::_instance = NULL;
return;
_instance = NULL;
- debugs(29, DBG_CRITICAL, "Shutdown: NTLM authentication.");
+ debugs(29, Critical(61), "Shutdown: NTLM authentication.");
}
Auth::SchemeConfig *
#include "ConfigOption.h"
#include "ConfigParser.h"
#include "CpuAffinityMap.h"
+#include "DebugMessages.h"
#include "DiskIO/DiskIOModule.h"
#include "eui/Config.h"
#include "ExternalACL.h"
// std::chrono::years requires C++20. Do our own rough calculation for now.
static const double HoursPerYear = 24*365.2522;
+static void parse_cache_log_message(DebugMessages **messages);
+static void dump_cache_log_message(StoreEntry *entry, const char *name, const DebugMessages *messages);
+static void free_cache_log_message(DebugMessages **messages);
+
static void parse_access_log(CustomLog ** customlog_definitions);
static int check_null_access_log(CustomLog *customlog_definitions);
static void dump_access_log(StoreEntry * entry, const char *name, CustomLog * definitions);
notes->clean();
}
+static DebugMessageId ParseDebugMessageId(const char *value, const char eov)
+{
+ const auto id = xatoui(value, eov);
+ if (!(0 < id && id < DebugMessageIdUpperBound))
+ throw TextException(ToSBuf("unknown cache_log_message ID: ", value), Here());
+ return static_cast<DebugMessageId>(id);
+}
+
+static void parse_cache_log_message(DebugMessages **debugMessages)
+{
+ DebugMessage msg;
+ DebugMessageId minId = 0;
+ DebugMessageId maxId = 0;
+
+ char *key = nullptr;
+ char *value = nullptr;
+ while (ConfigParser::NextKvPair(key, value)) {
+ if (strcmp(key, "id") == 0) {
+ if (minId > 0)
+ break;
+ minId = maxId = ParseDebugMessageId(value, '\0');
+ } else if (strcmp(key, "ids") == 0) {
+ if (minId > 0)
+ break;
+ const auto dash = strchr(value, '-');
+ if (!dash)
+ throw TextException(ToSBuf("malformed cache_log_message ID range: ", key, '=', value), Here());
+ minId = ParseDebugMessageId(value, '-');
+ maxId = ParseDebugMessageId(dash+1, '\0');
+ if (minId > maxId)
+ throw TextException(ToSBuf("invalid cache_log_message ID range: ", key, '=', value), Here());
+ } else if (strcmp(key, "level") == 0) {
+ if (msg.levelled())
+ break;
+ const auto level = xatoi(value);
+ if (level < 0)
+ throw TextException(ToSBuf("negative cache_log_message level: ", value), Here());
+ msg.level = level;
+ } else if (strcmp(key, "limit") == 0) {
+ if (msg.limited())
+ break;
+ msg.limit = xatoull(value, 10);
+ } else {
+ throw TextException(ToSBuf("unsupported cache_log_message option: ", key), Here());
+ }
+ key = value = nullptr;
+ }
+
+ if (key && value)
+ throw TextException(ToSBuf("repeated or conflicting cache_log_message option: ", key, '=', value), Here());
+
+ if (!minId)
+ throw TextException("cache_log_message is missing a required id=... or ids=... option", Here());
+
+ if (!(msg.levelled() || msg.limited()))
+ throw TextException("cache_log_message is missing a required level=... or limit=... option", Here());
+
+ assert(debugMessages);
+ if (!*debugMessages)
+ *debugMessages = new DebugMessages();
+
+ for (auto id = minId; id <= maxId; ++id) {
+ msg.id = id;
+ (*debugMessages)->messages.at(id) = msg;
+ }
+}
+
+static void dump_cache_log_message(StoreEntry *entry, const char *name, const DebugMessages *debugMessages)
+{
+ if (!debugMessages)
+ return;
+
+ SBufStream out;
+ for (const auto &msg: debugMessages->messages) {
+ if (!msg.configured())
+ continue;
+ out << name << " id=" << msg.id;
+ if (msg.levelled())
+ out << " level=" << msg.level;
+ if (msg.limited())
+ out << " limit=" << msg.limit;
+ out << "\n";
+ }
+ const auto buf = out.buf();
+ entry->append(buf.rawContent(), buf.length()); // may be empty
+}
+
+static void free_cache_log_message(DebugMessages **debugMessages)
+{
+ // clear old messages to avoid cumulative effect across (re)configurations
+ assert(debugMessages);
+ delete *debugMessages;
+ *debugMessages = nullptr;
+}
+
static bool FtpEspvDeprecated = false;
static void parse_ftp_epsv(acl_access **ftp_epsv)
{
sslproxy_cert_sign acl
sslproxy_cert_adapt acl
ftp_epsv acl
+cache_log_message
rotated with "debug_options"
DOC_END
+NAME: cache_log_message
+TYPE: cache_log_message
+DEFAULT: none
+DEFAULT_DOC: Use debug_options.
+LOC: Config.debugMessages
+DOC_START
+ Configures logging of individual cache.log messages.
+
+ cache_log_message id=<number> option...
+ cache_log_message ids=<number>-<number> option...
+
+ Most messages have _not_ been instrumented to support this directive
+ yet. For the list of instrumented messages and their IDs, please see
+ the doc/debug-messages.txt file.
+
+ Message ID corresponds to the message semantics rather than message
+ text or source code location. The ID is stable across Squid
+ instances and versions. Substantial changes in message semantics
+ result in a new ID assignment. To reduce the danger of suppressing
+ an important log message, the old IDs of removed (or substantially
+ changed) messages are never reused.
+
+ If more than one cache_log_message directive refers to the same
+ message ID, the last directive wins.
+
+ Use ids=min-max syntax to apply the same message configuration to an
+ inclusive range of message IDs. An ID range with N values has
+ exactly the same effect as typing N cache_log_message lines.
+
+ At least one option is required. Supported options are:
+
+ level=<number>: The logging level to use for the message. Squid
+ command line options (-s and -d) as well as the debug_options
+ directive control which levels go to syslog, stderr, and/or
+ cache.log. In most environments, using level=2 or higher stops
+ Squid from logging the message anywhere. By default, the
+ hard-coded message-specific level is used.
+
+ limit=<number>: After logging the specified number of messages at
+ the configured (or default) debugging level DL, start using
+ level 3 (for DL 0 and 1) or 8 (for higher DL values). Usually,
+ level-3+ messages are not logged anywhere so this option can
+ often be used to effectively suppress the message. Each SMP
+ Squid process gets the same limit.
+DOC_END
+
NAME: debug_options
TYPE: eol
DEFAULT: ALL,1
#include "comm/TcpAcceptor.h"
#include "comm/Write.h"
#include "CommCalls.h"
+#include "DebugMessages.h"
#include "error/ExceptionErrorDetail.h"
#include "errorpage.h"
#include "fd.h"
return;
case Security::IoResult::ioError:
- debugs(83, (handshakeResult.important ? DBG_IMPORTANT : 2), "ERROR: " << handshakeResult.errorDescription <<
+ debugs(83, (handshakeResult.important ? Important(62) : 2), "ERROR: " << handshakeResult.errorDescription <<
" while accepting a TLS connection on " << conn->clientConnection << ": " << handshakeResult.errorDetail);
// TODO: No ConnStateData::tunnelOnError() on this forward-proxy code
// path because we cannot know the intended connection target?
// TCP: setup a job to handle accept() with subscribed handler
AsyncJob::Start(new Comm::TcpAcceptor(s, FdNote(portTypeNote), sub));
- debugs(1, DBG_IMPORTANT, "Accepting " <<
+ debugs(1, Important(13), "Accepting " <<
(s->flags.natIntercept ? "NAT intercepted " : "") <<
(s->flags.tproxyIntercept ? "TPROXY intercepted " : "") <<
(s->flags.tunnelSslBumping ? "SSL bumped " : "") <<
{
for (AnyP::PortCfgPointer s = HttpPortList; s != NULL; s = s->next) {
if (s->listenConn != NULL) {
- debugs(1, DBG_IMPORTANT, "Closing HTTP(S) port " << s->listenConn->local);
+ debugs(1, Important(14), "Closing HTTP(S) port " << s->listenConn->local);
s->listenConn->close();
s->listenConn = NULL;
}
#include "squid.h"
#include "Debug.h"
+#include "DebugMessages.h"
#include "fd.h"
#include "ipc/Kids.h"
#include "SquidTime.h"
int Debug::Levels[MAX_DEBUG_SECTIONS];
char *Debug::cache_log = NULL;
int Debug::rotateNumber = -1;
+DebugMessages TheDebugMessages;
static int Ctx_Lock = 0;
static const char *debugLogTime(void);
static const char *debugLogKid(void);
#include "comm/Loops.h"
#include "comm/Read.h"
#include "comm/Write.h"
+#include "DebugMessages.h"
#include "dlink.h"
#include "dns/forward.h"
#include "dns/rfc3596.h"
{
bool result = false;
for (auto &i : Config.dns.nameservers) {
- debugs(78, DBG_IMPORTANT, "Adding nameserver " << i << " from squid.conf");
+ debugs(78, Important(15), "Adding nameserver " << i << " from squid.conf");
idnsAddNameserver(i.c_str());
result = true;
}
*/
if (DnsSocketB >= 0) {
comm_local_port(DnsSocketB);
- debugs(78, DBG_IMPORTANT, "DNS Socket created at " << addrV6 << ", FD " << DnsSocketB);
+ debugs(78, Important(16), "DNS IPv6 socket created at " << addrV6 << ", FD " << DnsSocketB);
Comm::SetSelect(DnsSocketB, COMM_SELECT_READ, idnsRead, NULL, 0);
}
if (DnsSocketA >= 0) {
comm_local_port(DnsSocketA);
- debugs(78, DBG_IMPORTANT, "DNS Socket created at " << addrV4 << ", FD " << DnsSocketA);
+ debugs(78, Important(64), "DNS IPv4 socket created at " << addrV4 << ", FD " << DnsSocketA);
Comm::SetSelect(DnsSocketA, COMM_SELECT_READ, idnsRead, NULL, 0);
}
}
#include "squid.h"
#include "comm/Loops.h"
#include "Debug.h"
+#include "DebugMessages.h"
#include "fatal.h"
#include "fd.h"
#include "fde.h"
if (i == fileno(debug_log))
continue;
- debugs(51, DBG_IMPORTANT, "Open FD "<< std::left<< std::setw(10) <<
+ debugs(51, Important(17), "Open FD "<< std::left<< std::setw(10) <<
(F->bytes_read && F->bytes_written ? "READ/WRITE" :
F->bytes_read ? "READING" : F->bytes_written ? "WRITING" :
"UNSTARTED") <<
#include "squid.h"
#include "base/AsyncJobCalls.h"
+#include "DebugMessages.h"
#include "fs/rock/RockDbCell.h"
#include "fs/rock/RockRebuild.h"
#include "fs/rock/RockSwapDir.h"
assert(IsResponsible(*sd));
if (!resuming) {
- debugs(47, DBG_IMPORTANT, "Loading cache_dir #" << sd->index <<
+ debugs(47, Important(18), "Loading cache_dir #" << sd->index <<
" from " << sd->filePath);
} else {
- debugs(47, DBG_IMPORTANT, "Resuming indexing cache_dir #" << sd->index <<
+ debugs(47, Important(63), "Resuming indexing cache_dir #" << sd->index <<
" from " << sd->filePath << ':' << progressDescription());
}
#include "comm/Connection.h"
#include "comm/Read.h"
#include "comm/Write.h"
+#include "DebugMessages.h"
#include "fd.h"
#include "fde.h"
#include "format/Quoting.h"
/* figure out how many new child are actually needed. */
int need_new = hlp->childs.needNew();
- debugs(84, DBG_IMPORTANT, "helperOpenServers: Starting " << need_new << "/" << hlp->childs.n_max << " '" << shortname << "' processes");
+ debugs(84, Important(19), "helperOpenServers: Starting " << need_new << "/" << hlp->childs.n_max << " '" << shortname << "' processes");
if (need_new < 1) {
- debugs(84, DBG_IMPORTANT, "helperOpenServers: No '" << shortname << "' processes needed.");
+ debugs(84, Important(20), "helperOpenServers: No '" << shortname << "' processes needed.");
}
procname = (char *)xmalloc(strlen(shortname) + 3);
#include "comm/Loops.h"
#include "comm/UdpOpenDialer.h"
#include "compat/xalloc.h"
+#include "DebugMessages.h"
#include "globals.h"
#include "htcp.h"
#include "http.h"
htcpOpenPorts(void)
{
if (Config.Port.htcp <= 0) {
- debugs(31, DBG_IMPORTANT, "HTCP Disabled.");
+ debugs(31, Important(21), "HTCP Disabled.");
return;
}
#include "squid.h"
#include "CacheManager.h"
#include "cbdata.h"
+#include "DebugMessages.h"
#include "dlink.h"
#include "dns/LookupDetails.h"
#include "dns/rfc3596.h"
ipcache_init(void)
{
int n;
- debugs(14, DBG_IMPORTANT, "Initializing IP Cache...");
+ debugs(14, Important(24), "Initializing IP Cache...");
memset(&IpcacheStats, '\0', sizeof(IpcacheStats));
lru_list = dlink_list();
/* DEBUG: section 50 Log file handling */
#include "squid.h"
+#include "DebugMessages.h"
#include "fatal.h"
#include "fde.h"
#include "log/File.h"
int ret;
const char *patharg;
- debugs(50, DBG_IMPORTANT, "Logfile: opening log " << path);
+ debugs(50, Important(26), "Logfile: opening log " << path);
Logfile *lf = new Logfile(path);
patharg = path;
void
logfileClose(Logfile * lf)
{
- debugs(50, DBG_IMPORTANT, "Logfile: closing log " << lf->path);
+ debugs(50, Important(27), "Logfile: closing log " << lf->path);
lf->f_flush(lf);
lf->f_close(lf);
delete lf;
#include "CommandLine.h"
#include "ConfigParser.h"
#include "CpuAffinity.h"
+#include "DebugMessages.h"
#include "DiskIO/DiskIOModule.h"
#include "dns/forward.h"
#include "errorpage.h"
if (AvoidSignalAction("shutdown", do_shutdown))
return;
- debugs(1, DBG_IMPORTANT, "Preparing for shutdown after " << statCounter.client_http.requests << " requests");
- debugs(1, DBG_IMPORTANT, "Waiting " << wait << " seconds for active connections to finish");
+ debugs(1, Important(2), "Preparing for shutdown after " << statCounter.client_http.requests << " requests");
+ debugs(1, Important(3), "Waiting " << wait << " seconds for active connections to finish");
#if KILL_PARENT_OPT
if (!IamMasterProcess() && !parentKillNotified && ShutdownSignal > 0 && parentPid > 1) {
if (Config.coredump_dir && strcmp("none", Config.coredump_dir) != 0) {
if (mainChangeDir(Config.coredump_dir)) {
- debugs(0, DBG_IMPORTANT, "Set Current Directory to " << Config.coredump_dir);
+ debugs(0, Important(4), "Set Current Directory to " << Config.coredump_dir);
return;
}
}
Config.Port.icp = (unsigned short) icpPortNumOverride;
debugs(1, DBG_CRITICAL, "Starting Squid Cache version " << version_string << " for " << CONFIG_HOST_TYPE << "...");
- debugs(1, DBG_CRITICAL, "Service Name: " << service_name);
+ debugs(1, Critical(5), "Service Name: " << service_name);
#if _SQUID_WINDOWS_
if (WIN32_run_mode == _WIN_SQUID_RUN_MODE_SERVICE) {
debugs(1, DBG_CRITICAL, "Running on " << WIN32_OS_string);
#endif
- debugs(1, DBG_IMPORTANT, "Process ID " << getpid());
+ debugs(1, Important(6), "Process ID " << getpid());
- debugs(1, DBG_IMPORTANT, "Process Roles:" << ProcessRoles());
+ debugs(1, Important(7), "Process Roles:" << ProcessRoles());
setSystemLimits();
- debugs(1, DBG_IMPORTANT, "With " << Squid_MaxFD << " file descriptors available");
+ debugs(1, Important(8), "With " << Squid_MaxFD << " file descriptors available");
#if _SQUID_WINDOWS_
WIN32_svcstatusupdate(SERVICE_STOP_PENDING, 10000);
#endif
- debugs(1, DBG_IMPORTANT, "Shutting down...");
+ debugs(1, Important(9), "Shutting down...");
#if USE_SSL_CRTD
Ssl::Helper::Shutdown();
#endif
memClean();
- debugs(1, DBG_IMPORTANT, "Squid Cache (Version " << version_string << "): Exiting normally.");
+ debugs(1, Important(10), "Squid Cache (Version " << version_string << "): Exiting normally.");
/*
* DPW 2006-10-23
/* DEBUG: section 25 MIME Parsing and Internal Icons */
#include "squid.h"
+#include "DebugMessages.h"
#include "fde.h"
#include "fs_io.h"
#include "globals.h"
for (m = MimeTable; m != NULL; m = m->next)
m->theIcon.load();
- debugs(25, DBG_IMPORTANT, "Finished loading MIME types and icons.");
+ debugs(25, Important(28), "Finished loading MIME types and icons.");
}
void
#include "CachePeer.h"
#include "comm/Connection.h"
#include "comm/ConnOpener.h"
+#include "DebugMessages.h"
#include "event.h"
#include "FwdState.h"
#include "globals.h"
CachePeer *p = (CachePeer *)data;
if (p->n_addresses == 0) {
- debugs(15, DBG_IMPORTANT, "Configuring " << neighborTypeStr(p) << " " << p->host << "/" << p->http_port << "/" << p->icp.port);
+ debugs(15, Important(29), "Configuring " << neighborTypeStr(p) << " " << p->host << "/" << p->http_port << "/" << p->icp.port);
if (p->type == PEER_MULTICAST)
debugs(15, DBG_IMPORTANT, " Multicast TTL = " << p->mcast.ttl);
#include "CollapsedForwarding.h"
#include "comm/Connection.h"
#include "comm/Read.h"
+#include "DebugMessages.h"
#if HAVE_DISKIO_MODULE_IPCIO
#include "DiskIO/IpcIo/IpcIoFile.h"
#endif
// TODO: this works but looks unelegant.
for (int i = 0; i < 10; ++i) {
if (LateReleaseStack.empty()) {
- debugs(20, DBG_IMPORTANT, "storeLateRelease: released " << n << " objects");
+ debugs(20, Important(30), "storeLateRelease: released " << n << " objects");
return;
} else {
e = LateReleaseStack.top();
#include "cache_cf.h"
#include "ConfigParser.h"
#include "Debug.h"
+#include "DebugMessages.h"
#include "globals.h"
#include "profiler/Profiler.h"
#include "sbuf/Stream.h"
/* this is very bogus, its specific to the any Store maintaining an
* in-core index, not global */
size_t buckets = (Store::Root().maxSize() + Config.memMaxSize) / Config.Store.avgObjectSize;
- debugs(20, DBG_IMPORTANT, "Swap maxSize " << (Store::Root().maxSize() >> 10) <<
+ debugs(20, Important(31), "Swap maxSize " << (Store::Root().maxSize() >> 10) <<
" + " << ( Config.memMaxSize >> 10) << " KB, estimated " << buckets << " objects");
buckets /= Config.Store.objectsPerBucket;
- debugs(20, DBG_IMPORTANT, "Target number of buckets: " << buckets);
+ debugs(20, Important(32), "Target number of buckets: " << buckets);
/* ideally the full scan period should be configurable, for the
* moment it remains at approximately 24 hours. */
store_hash_buckets = storeKeyHashBuckets(buckets);
- debugs(20, DBG_IMPORTANT, "Using " << store_hash_buckets << " Store buckets");
- debugs(20, DBG_IMPORTANT, "Max Mem size: " << ( Config.memMaxSize >> 10) << " KB" <<
+ debugs(20, Important(33), "Using " << store_hash_buckets << " Store buckets");
+ debugs(20, Important(34), "Max Mem size: " << ( Config.memMaxSize >> 10) << " KB" <<
(Config.memShared ? " [shared]" : ""));
- debugs(20, DBG_IMPORTANT, "Max Swap size: " << (Store::Root().maxSize() >> 10) << " KB");
+ debugs(20, Important(35), "Max Swap size: " << (Store::Root().maxSize() >> 10) << " KB");
store_table = hash_create(storeKeyHashCmp,
store_hash_buckets, storeKeyHashHash);
debugs(47, DBG_IMPORTANT, "Using Round Robin store dir selection");
} else {
storeDirSelectSwapDir = storeDirSelectSwapDirLeastLoad;
- debugs(47, DBG_IMPORTANT, "Using Least Load store dir selection");
+ debugs(47, Important(36), "Using Least Load store dir selection");
}
}
// initialization phases, before store log is initialized and ready. Also,
// some stores do not support log cleanup during Store rebuilding.
if (StoreController::store_dirs_rebuilding) {
- debugs(20, DBG_IMPORTANT, "Not currently OK to rewrite swap log.");
- debugs(20, DBG_IMPORTANT, "storeDirWriteCleanLogs: Operation aborted.");
+ debugs(20, Important(37), "Not currently OK to rewrite swap log.");
+ debugs(20, Important(38), "storeDirWriteCleanLogs: Operation aborted.");
return 0;
}
- debugs(20, DBG_IMPORTANT, "storeDirWriteCleanLogs: Starting...");
+ debugs(20, Important(39), "storeDirWriteCleanLogs: Starting...");
getCurrentTime();
start = current_time;
dt = tvSubDsec(start, current_time);
- debugs(20, DBG_IMPORTANT, " Finished. Wrote " << n << " entries.");
- debugs(20, DBG_IMPORTANT, " Took "<< std::setw(3)<< std::setprecision(2) << dt <<
+ debugs(20, Important(40), " Finished. Wrote " << n << " entries.");
+ debugs(20, Important(41), " Took "<< std::setw(3) << std::setprecision(2) << dt <<
" seconds ("<< std::setw(6) << ((double) n / (dt > 0.0 ? dt : 1.0)) << " entries/sec).");
return n;
/* DEBUG: section 20 Storage Manager Logging Functions */
#include "squid.h"
+#include "DebugMessages.h"
#include "format/Token.h"
#include "HttpReply.h"
#include "log/File.h"
storeLogRegisterWithCacheManager();
if (Config.Log.store == NULL || strcmp(Config.Log.store, "none") == 0) {
- debugs(20, DBG_IMPORTANT, "Store logging disabled");
+ debugs(20, Important(42), "Store logging disabled");
return;
}
/* DEBUG: section 20 Store Rebuild Routines */
#include "squid.h"
+#include "DebugMessages.h"
#include "event.h"
#include "globals.h"
#include "md5.h"
if (currentSearch->isDone()) {
debugs(20, 2, "Seen: " << seen << " entries");
- debugs(20, DBG_IMPORTANT, " Completed Validation Procedure");
- debugs(20, DBG_IMPORTANT, " Validated " << validated << " Entries");
- debugs(20, DBG_IMPORTANT, " store_swap_size = " << Store::Root().currentSize() / 1024.0 << " KB");
+ debugs(20, Important(43), "Completed Validation Procedure" <<
+ Debug::Extra << "Validated " << validated << " Entries" <<
+ Debug::Extra << "store_swap_size = " << (Store::Root().currentSize()/1024.0) << " KB");
--StoreController::store_dirs_rebuilding;
assert(0 == StoreController::store_dirs_rebuilding);
const auto dt = tvSubDsec(counts.startTime, current_time);
- debugs(20, DBG_IMPORTANT, "Finished rebuilding storage from disk.");
- debugs(20, DBG_IMPORTANT, " " << std::setw(7) << counts.scancount << " Entries scanned");
- debugs(20, DBG_IMPORTANT, " " << std::setw(7) << counts.invalid << " Invalid entries.");
- debugs(20, DBG_IMPORTANT, " " << std::setw(7) << counts.badflags << " With invalid flags.");
- debugs(20, DBG_IMPORTANT, " " << std::setw(7) << counts.objcount << " Objects loaded.");
- debugs(20, DBG_IMPORTANT, " " << std::setw(7) << counts.expcount << " Objects expired.");
- debugs(20, DBG_IMPORTANT, " " << std::setw(7) << counts.cancelcount << " Objects cancelled.");
- debugs(20, DBG_IMPORTANT, " " << std::setw(7) << counts.dupcount << " Duplicate URLs purged.");
- debugs(20, DBG_IMPORTANT, " " << std::setw(7) << counts.clashcount << " Swapfile clashes avoided.");
- debugs(20, DBG_IMPORTANT, " Took "<< std::setw(3)<< std::setprecision(2) << dt << " seconds ("<< std::setw(6) <<
+ debugs(20, Important(46), "Finished rebuilding storage from disk." <<
+ Debug::Extra << std::setw(7) << counts.scancount << " Entries scanned" <<
+ Debug::Extra << std::setw(7) << counts.invalid << " Invalid entries" <<
+ Debug::Extra << std::setw(7) << counts.badflags << " With invalid flags" <<
+ Debug::Extra << std::setw(7) << counts.objcount << " Objects loaded" <<
+ Debug::Extra << std::setw(7) << counts.expcount << " Objects expired" <<
+ Debug::Extra << std::setw(7) << counts.cancelcount << " Objects canceled" <<
+ Debug::Extra << std::setw(7) << counts.dupcount << " Duplicate URLs purged" <<
+ Debug::Extra << std::setw(7) << counts.clashcount << " Swapfile clashes avoided" <<
+ Debug::Extra << "Took " << std::setprecision(2) << dt << " seconds (" <<
((double) counts.objcount / (dt > 0.0 ? dt : 1.0)) << " objects/sec).");
- debugs(20, DBG_IMPORTANT, "Beginning Validation Procedure");
+ debugs(20, Important(56), "Beginning Validation Procedure");
eventAdd("storeCleanup", storeCleanup, NULL, 0.0, 1);
d += (double) RebuildProgress[sd_index].total;
}
- debugs(20, DBG_IMPORTANT, "Indexing cache entries: " << Progress(n, d));
+ debugs(20, Important(57), "Indexing cache entries: " << Progress(n, d));
last_report = squid_curtime;
}