]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
cache_log_message directive (#775)
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Fri, 11 Jun 2021 13:24:04 +0000 (13:24 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Fri, 11 Jun 2021 13:24:08 +0000 (13:24 +0000)
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.

35 files changed:
doc/Makefile.am
doc/debug-messages.dox [new file with mode: 0644]
scripts/source-maintenance.sh
src/DebugMessages.h [new file with mode: 0644]
src/Instance.cc
src/LoadableModules.cc
src/Makefile.am
src/Parsing.cc
src/Parsing.h
src/SquidConfig.h
src/acl/FilledChecklist.cc
src/adaptation/Config.cc
src/auth/basic/Scheme.cc
src/auth/digest/Scheme.cc
src/auth/negotiate/Scheme.cc
src/auth/ntlm/Scheme.cc
src/cache_cf.cc
src/cf.data.depend
src/cf.data.pre
src/client_side.cc
src/debug.cc
src/dns_internal.cc
src/fd.cc
src/fs/rock/RockRebuild.cc
src/helper.cc
src/htcp.cc
src/ipcache.cc
src/log/File.cc
src/main.cc
src/mime.cc
src/neighbors.cc
src/store.cc
src/store/Disks.cc
src/store_log.cc
src/store_rebuild.cc

index 3ab4ffa5efe0893ffb38fb82781d161fc5de3cf6..39970a958f4617d6e86ddee24db6ff0c559f673b 100644 (file)
@@ -12,4 +12,5 @@ DEFAULT_MIME_TABLE      = $(sysconfdir)/mime.conf
 DEFAULT_ERROR_DIR       = $(datadir)/errors
 
 EXTRA_DIST = \
+       debug-messages.dox \
        debug-sections.txt
diff --git a/doc/debug-messages.dox b/doc/debug-messages.dox
new file mode 100644 (file)
index 0000000..7ed7fcf
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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
+*/
index 8d5a64d5a2319f38aa4ac11a4b429bf2c4895d71..4a3451d52fbd9f0762e9d424288bb34e217423b0 100755 (executable)
@@ -202,8 +202,110 @@ checkMakeNamedErrorDetails ()
     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
 #
@@ -301,6 +403,8 @@ for FILENAME in `git ls-files`; do
                echo "ERROR: ${FILENAME} contains unsafe use of sprintf()"
        fi
 
+       collectDebugMessagesFrom ${FILENAME}
+
        #
        # DEBUG Section list maintenance
        #
@@ -353,6 +457,9 @@ for FILENAME in `git ls-files`; do
     fi
 
 done
+
+    run_ processDebugSections || return
+    run_ processDebugMessages || return
 }
 
 # Build XPROF types file from current sources
@@ -405,11 +512,8 @@ make -C src/http gperf-files
 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
diff --git a/src/DebugMessages.h b/src/DebugMessages.h
new file mode 100644 (file)
index 0000000..66c1a6e
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * 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 */
+
index 842d65dbf608c45e97eff52f5bd60a545c47ac55..2b95b777377a2316ffa99a9586fa8cb583743627 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "squid.h"
 #include "base/File.h"
+#include "DebugMessages.h"
 #include "fs_io.h"
 #include "Instance.h"
 #include "parser/Tokenizer.h"
@@ -163,7 +164,7 @@ RemoveInstance()
     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);
@@ -210,6 +211,6 @@ Instance::WriteOurPid()
     // 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);
 }
 
index 6c695455fd5856c560d1c9de1af7e0135ad329ad..16a6655555cceae79469f73aa93a072c16fe8d86 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "squid.h"
 #include "Debug.h"
+#include "DebugMessages.h"
 #include "LoadableModule.h"
 #include "LoadableModules.h"
 #include "wordlist.h"
@@ -30,6 +31,6 @@ LoadableModulesConfigure(const wordlist *names)
     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);
 }
 
index efafea7cb88168c36e853b70d9e7ab1e70de90e5..63f1b3fa306d058525fe9d26b6ab08cf11eb49b3 100644 (file)
@@ -251,6 +251,7 @@ squid_SOURCES = \
        CpuAffinitySet.cc \
        CpuAffinitySet.h \
        Debug.h \
+       DebugMessages.h \
        Downloader.cc \
        Downloader.h \
        ETag.cc \
index a5c5981705a89380eef7074c18c8bc6d06f65098..5dfd3cf9b461985c9d2b17d83902cf049d58e8b6 100644 (file)
@@ -15,6 +15,7 @@
 #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
@@ -57,16 +58,12 @@ unsigned int
 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;
 }
@@ -104,6 +101,15 @@ xatoll(const char *token, int base, char eov)
     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)
 {
index 9967b3d69baedce1e588e9e82fc3a3b03c365a4e..4b50f00fa7be7efca95d1ac824e6df22d68f2429 100644 (file)
@@ -18,6 +18,7 @@ int xatoi(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);
 
 /**
index a680d006c5d72d2e85f0494f80c022aa644d8b7c..0117ea78083f4d7f16a7eec2e0187b0bcf5f8c11 100644 (file)
@@ -45,6 +45,7 @@ class ActionPasswordList;
 class CachePeer;
 class CustomLog;
 class CpuAffinityMap;
+class DebugMessages;
 class external_acl;
 class HeaderManglers;
 class RefreshPattern;
@@ -559,6 +560,8 @@ public:
         int connect_gap;
         int connect_timeout;
     } happyEyeballs;
+
+    DebugMessages *debugMessages; ///< cache_log_message
 };
 
 extern SquidConfig Config;
index d2aa2d12dc17afd255d27cd1a3f2948ab129144b..ac24664e82f36e41c9add7cdc11b2569fc4f9cd8 100644 (file)
@@ -11,6 +11,7 @@
 #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"
@@ -75,7 +76,7 @@ showDebugWarning(const char *msg)
         return;
 
     ++count;
-    debugs(28, DBG_IMPORTANT, "ALE missing " << msg);
+    debugs(28, Important(58), "ALE missing " << msg);
 }
 
 void
index b90fea802773e4a86b55e26c6713e13c13e6ac3c..95bcf99bbe7cea63a13f557a9ab63576252191fd 100644 (file)
@@ -15,6 +15,7 @@
 #include "adaptation/Service.h"
 #include "adaptation/ServiceGroups.h"
 #include "ConfigParser.h"
+#include "DebugMessages.h"
 #include "globals.h"
 #include "HttpReply.h"
 #include "HttpRequest.h"
@@ -228,7 +229,7 @@ void
 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");
index bf0be941f6e3f8b6ae07a782333dbb2c39bd5d3c..5d8161a898a925c896e90f4ffe387fe7b3fa7f32 100644 (file)
@@ -10,6 +10,7 @@
 #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;
@@ -37,7 +38,7 @@ Auth::Basic::Scheme::shutdownCleanup()
         return;
 
     _instance = NULL;
-    debugs(29, DBG_CRITICAL, "Shutdown: Basic authentication.");
+    debugs(29, Critical(12), "Shutdown: Basic authentication.");
 }
 
 Auth::SchemeConfig *
index e0fa9997ad2c47f3e10ea7dc277b049c080240fc..ef46f0022d720371779e1772d0e31d210d87dc43 100644 (file)
@@ -10,6 +10,7 @@
 #include "auth/digest/Config.h"
 #include "auth/digest/Scheme.h"
 #include "Debug.h"
+#include "DebugMessages.h"
 #include "globals.h"
 #include "helper.h"
 
@@ -40,7 +41,7 @@ Auth::Digest::Scheme::shutdownCleanup()
     authenticateDigestNonceShutdown();
 
     _instance = NULL;
-    debugs(29, DBG_CRITICAL, "Shutdown: Digest authentication.");
+    debugs(29, Critical(59), "Shutdown: Digest authentication.");
 }
 
 Auth::SchemeConfig *
index ffa6e761453133021668ae4f8930bbe600311e9d..724620379a0e3f7f34fa743ffc1daf0cf1e31504 100644 (file)
@@ -10,6 +10,7 @@
 #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;
@@ -37,7 +38,7 @@ Auth::Negotiate::Scheme::shutdownCleanup()
         return;
 
     _instance = NULL;
-    debugs(29, DBG_CRITICAL, "Shutdown: Negotiate authentication.");
+    debugs(29, Critical(60), "Shutdown: Negotiate authentication.");
 }
 
 Auth::SchemeConfig *
index d869b71af574bb5a2ee597365343080e2433bd85..03e8106ea2f7d7716ab80997923a59a8b7dbbc37 100644 (file)
@@ -10,6 +10,7 @@
 #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;
@@ -37,7 +38,7 @@ Auth::Ntlm::Scheme::shutdownCleanup()
         return;
 
     _instance = NULL;
-    debugs(29, DBG_CRITICAL, "Shutdown: NTLM authentication.");
+    debugs(29, Critical(61), "Shutdown: NTLM authentication.");
 }
 
 Auth::SchemeConfig *
index 46ea3facf30f5381d9a74cd2454ec0e4fd463368..1d7950c61d4bcb96428315a9a9f6ec82c92f872d 100644 (file)
@@ -28,6 +28,7 @@
 #include "ConfigOption.h"
 #include "ConfigParser.h"
 #include "CpuAffinityMap.h"
+#include "DebugMessages.h"
 #include "DiskIO/DiskIOModule.h"
 #include "eui/Config.h"
 #include "ExternalACL.h"
@@ -162,6 +163,10 @@ static const char *const list_sep = ", \t\n\r";
 // 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);
@@ -4658,6 +4663,101 @@ static void free_note(Notes *notes)
     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)
 {
index 036009bf93b86bfbf26aab72021c0735cd8eba30..ffda0e0de44624bb35ba334fb8890280f1b4fcd0 100644 (file)
@@ -97,3 +97,4 @@ sslproxy_ssl_bump_peeked acl
 sslproxy_cert_sign     acl
 sslproxy_cert_adapt    acl
 ftp_epsv                acl
+cache_log_message
index de9369fdd4f1682471c5a9b7d6b2f2db4e19ba3c..a5d0624b7ef5f2d81866d713af5c2aeaecb0822b 100644 (file)
@@ -5534,6 +5534,52 @@ DOC_START
        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
index 69175d4dc6e94ddd402e69f308f52cdcc363c059..ddaef05ec7a399c96eb14a00f26dccb10b237dc0 100644 (file)
@@ -76,6 +76,7 @@
 #include "comm/TcpAcceptor.h"
 #include "comm/Write.h"
 #include "CommCalls.h"
+#include "DebugMessages.h"
 #include "error/ExceptionErrorDetail.h"
 #include "errorpage.h"
 #include "fd.h"
@@ -2401,7 +2402,7 @@ clientNegotiateSSL(int fd, void *data)
         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?
@@ -3455,7 +3456,7 @@ clientListenerConnectionOpened(AnyP::PortCfgPointer &s, const Ipc::FdNoteId port
     // 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 " : "") <<
@@ -3495,7 +3496,7 @@ clientConnectionsClose()
 {
     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;
         }
index 319f470263b48c50c16219b8ca36b5d6607a469e..c66e13cc5b34eb64642578439c8075713a248145 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "squid.h"
 #include "Debug.h"
+#include "DebugMessages.h"
 #include "fd.h"
 #include "ipc/Kids.h"
 #include "SquidTime.h"
@@ -27,6 +28,7 @@ bool Debug::log_syslog = false;
 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);
index d75f42ad3546e16615578543694a05b72f63ce22..cdb34cf201f048cc41ed8da7df05d56411d18c9b 100644 (file)
@@ -18,6 +18,7 @@
 #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"
@@ -395,7 +396,7 @@ idnsParseNameservers(void)
 {
     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;
     }
@@ -1574,12 +1575,12 @@ Dns::Init(void)
          */
         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);
         }
     }
index fba7e0a57e78346c6f209bf713d322d15bae3333..8dbb9775144e05ba133f7dc96bdf353686aa2fd8 100644 (file)
--- a/src/fd.cc
+++ b/src/fd.cc
@@ -11,6 +11,7 @@
 #include "squid.h"
 #include "comm/Loops.h"
 #include "Debug.h"
+#include "DebugMessages.h"
 #include "fatal.h"
 #include "fd.h"
 #include "fde.h"
@@ -283,7 +284,7 @@ fdDumpOpen(void)
         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")  <<
index d5b5815c6b0856efa693c11c62646fdd63bf1f07..2d350c3751a706464cd68bfeb705b8fa4675f055 100644 (file)
@@ -10,6 +10,7 @@
 
 #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"
@@ -339,10 +340,10 @@ Rock::Rebuild::start()
     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());
     }
 
index f69e384faf69af2325cf9406bea96a42376abf4c..18460f0d37eec7b04478d829c7929e624f292b2e 100644 (file)
@@ -15,6 +15,7 @@
 #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"
@@ -223,10 +224,10 @@ helperOpenServers(helper * hlp)
     /* 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);
index 523c40832e927d2c23833819ff006a5713dea256..7a2aace075b25b800d33e73dc899b62f5b74f347 100644 (file)
@@ -18,6 +18,7 @@
 #include "comm/Loops.h"
 #include "comm/UdpOpenDialer.h"
 #include "compat/xalloc.h"
+#include "DebugMessages.h"
 #include "globals.h"
 #include "htcp.h"
 #include "http.h"
@@ -1438,7 +1439,7 @@ void
 htcpOpenPorts(void)
 {
     if (Config.Port.htcp <= 0) {
-        debugs(31, DBG_IMPORTANT, "HTCP Disabled.");
+        debugs(31, Important(21), "HTCP Disabled.");
         return;
     }
 
index 192011cc8cc0acd7a87d2ee0638078c7580c7b17..961358b8e2aa24031211f90e39675c70603d7b92 100644 (file)
@@ -11,6 +11,7 @@
 #include "squid.h"
 #include "CacheManager.h"
 #include "cbdata.h"
+#include "DebugMessages.h"
 #include "dlink.h"
 #include "dns/LookupDetails.h"
 #include "dns/rfc3596.h"
@@ -685,7 +686,7 @@ void
 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();
 
index af185b4a4094b31957da71d7bc21962f5ad3419b..39c8e3d35cd33cdf846e072fa2a9894c77891bc4 100644 (file)
@@ -9,6 +9,7 @@
 /* DEBUG: section 50    Log file handling */
 
 #include "squid.h"
+#include "DebugMessages.h"
 #include "fatal.h"
 #include "fde.h"
 #include "log/File.h"
@@ -41,7 +42,7 @@ logfileOpen(const char *path, size_t bufsz, int fatal_flag)
     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;
@@ -90,7 +91,7 @@ logfileOpen(const char *path, size_t bufsz, int fatal_flag)
 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;
index e0f94492360dda1307d2a5ff19c249a41e93cad3..29bb7bd1c4e1ef59fdf782cf418b6de18574923c 100644 (file)
@@ -29,6 +29,7 @@
 #include "CommandLine.h"
 #include "ConfigParser.h"
 #include "CpuAffinity.h"
+#include "DebugMessages.h"
 #include "DiskIO/DiskIOModule.h"
 #include "dns/forward.h"
 #include "errorpage.h"
@@ -290,8 +291,8 @@ SignalEngine::doShutdown(time_t wait)
     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) {
@@ -1117,7 +1118,7 @@ mainSetCwd(void)
 
     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;
         }
     }
@@ -1150,7 +1151,7 @@ mainInitialize(void)
         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) {
@@ -1159,12 +1160,12 @@ mainInitialize(void)
         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_
 
@@ -2084,7 +2085,7 @@ SquidShutdown()
     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
@@ -2168,7 +2169,7 @@ SquidShutdown()
 
     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
index 6c41421b06000eeefdd4be5c0eb383a8bbfce5cf..b108931167f099870c2f01f7226e298b7a1d32dd 100644 (file)
@@ -9,6 +9,7 @@
 /* DEBUG: section 25    MIME Parsing and Internal Icons */
 
 #include "squid.h"
+#include "DebugMessages.h"
 #include "fde.h"
 #include "fs_io.h"
 #include "globals.h"
@@ -331,7 +332,7 @@ mimeInit(char *filename)
 
     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
index ce2e6182ba35fe83490842224dac45cf07c3bd14..488d1a154d0cf60a78d9d04242f1077de4c74d77 100644 (file)
@@ -16,6 +16,7 @@
 #include "CachePeer.h"
 #include "comm/Connection.h"
 #include "comm/ConnOpener.h"
+#include "DebugMessages.h"
 #include "event.h"
 #include "FwdState.h"
 #include "globals.h"
@@ -1198,7 +1199,7 @@ peerDNSConfigure(const ipcache_addrs *ia, const Dns::LookupDetails &, void *data
     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);
index aefc66c46ad6667e6dfa7cc8e2d90f8a4f178abf..6cb14e49344074bda1870b501ac8073fc963e92b 100644 (file)
@@ -17,6 +17,7 @@
 #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
@@ -1195,7 +1196,7 @@ storeLateRelease(void *)
     // 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();
index 6747f6288043bad0f03aba02d93b415eed8ec45a..b85da0f38df0cc99684e2145a7e26ee90acde356 100644 (file)
@@ -12,6 +12,7 @@
 #include "cache_cf.h"
 #include "ConfigParser.h"
 #include "Debug.h"
+#include "DebugMessages.h"
 #include "globals.h"
 #include "profiler/Profiler.h"
 #include "sbuf/Stream.h"
@@ -269,17 +270,17 @@ Store::Disks::init()
     /* 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);
@@ -315,7 +316,7 @@ Store::Disks::init()
         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");
     }
 }
 
@@ -708,12 +709,12 @@ storeDirWriteCleanLogs(int reopen)
     // 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;
 
@@ -771,8 +772,8 @@ storeDirWriteCleanLogs(int reopen)
 
     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;
index cd4def9c2b06daec12dc32eeed4450c0b533a8c4..f7b70d963f92e01c9003b477b3504a503a6cbc48 100644 (file)
@@ -9,6 +9,7 @@
 /* DEBUG: section 20    Storage Manager Logging Functions */
 
 #include "squid.h"
+#include "DebugMessages.h"
 #include "format/Token.h"
 #include "HttpReply.h"
 #include "log/File.h"
@@ -125,7 +126,7 @@ storeLogOpen(void)
     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;
     }
 
index d3c38a89b509fac4d25b581b99e1b1422c937612..13da2ce0cd8a91a7dd6468ed51b348568a6c26ed 100644 (file)
@@ -9,6 +9,7 @@
 /* DEBUG: section 20    Store Rebuild Routines */
 
 #include "squid.h"
+#include "DebugMessages.h"
 #include "event.h"
 #include "globals.h"
 #include "md5.h"
@@ -96,9 +97,9 @@ storeCleanup(void *)
 
     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);
 
@@ -152,18 +153,18 @@ storeRebuildComplete(StoreRebuildData *dc)
 
     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);
 
@@ -229,7 +230,7 @@ storeRebuildProgress(int sd_index, int total, int sofar)
         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;
 }