]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix a few level-2+ debugs(); improve ErrorState debugging (#804)
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Sun, 18 Apr 2021 15:06:12 +0000 (15:06 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Tue, 20 Apr 2021 21:42:42 +0000 (21:42 +0000)
When possible, report object contents rather than its memory address.

src/HttpHdrRange.cc
src/HttpHdrSc.cc
src/errorpage.cc
src/errorpage.h
src/tests/stub_errorpage.cc

index 273f700370af82b2f7903c03cc4ff52c51a3788d..80fe70392017679402550c67eb43d5cad89acc47 100644 (file)
@@ -226,7 +226,7 @@ HttpHdrRange::parseInit(const String * range_spec)
     int ilen;
     assert(range_spec);
     ++ParsedCount;
-    debugs(64, 8, "parsing range field: '" << range_spec << "'");
+    debugs(64, 8, "parsing range field: '" << *range_spec << "'");
     /* check range type */
 
     if (range_spec->caseCmp("bytes=", 6))
@@ -247,7 +247,7 @@ HttpHdrRange::parseInit(const String * range_spec)
                 delete specs.back();
                 specs.pop_back();
             }
-            debugs(64, 2, "ignoring invalid range field: '" << range_spec << "'");
+            debugs(64, 2, "ignoring invalid range field: '" << *range_spec << "'");
             break;
         }
 
index b07c73f64aeb983c73a3c02c8aa6c6777e6a9cee..d0adfe32c3152c808ae1a57bd7e0dff6c14a0cd3 100644 (file)
@@ -108,7 +108,7 @@ HttpHdrSc::parse(const String * str)
         type = scLookupTable.lookup(SBuf(item,ilen));
 
         if (type == SC_ENUM_END) {
-            debugs(90, 2, "hdr sc: unknown control-directive: near '" << item << "' in '" << str << "'");
+            debugs(90, 2, "unknown control-directive near '" << item << "' in '" << *str << "'");
             type = SC_OTHER;
         }
 
@@ -134,7 +134,7 @@ HttpHdrSc::parse(const String * str)
 
         if (sct->isSet(type)) {
             if (type != SC_OTHER)
-                debugs(90, 2, "hdr sc: ignoring duplicate control-directive: near '" << item << "' in '" << str << "'");
+                debugs(90, 2, "ignoring duplicate control-directive near '" << item << "' in '" << *str << "'");
 
             ++ scHeaderStats[type].repCount;
 
index 50706788e9b7d9dc2950fd93ec62d5bcf3ea1f90..b360cc811c60f4c701c33bf46f2b50a20bd22975 100644 (file)
@@ -717,9 +717,7 @@ errorAppendEntry(StoreEntry * entry, ErrorState * err)
 {
     assert(entry->mem_obj != NULL);
     assert (entry->isEmpty());
-    debugs(4, 4, "Creating an error page for entry " << entry <<
-           " with errorstate " << err <<
-           " page id " << err->page_id);
+    debugs(4, 4, "storing " << err << " in " << *entry);
 
     if (entry->store_status != STORE_PENDING) {
         debugs(4, 2, "Skipping error page due to store_status: " << entry->store_status);
@@ -1388,7 +1386,7 @@ ErrorState::buildBody()
     if (!Config.errorDirectory)
         err_language = Config.errorDefaultLanguage;
 #endif
-    debugs(4, 2, "No existing error page language negotiated for " << errorPageName(page_id) << ". Using default error file.");
+    debugs(4, 2, "No existing error page language negotiated for " << this << ". Using default error file.");
     return compileBody(error_text[page_id], true);
 }
 
@@ -1523,3 +1521,13 @@ ErrorPage::ValidateStaticError(const int page_id, const SBuf &inputLocation)
     anErr.validate();
 }
 
+std::ostream &
+operator <<(std::ostream &os, const ErrorState *err)
+{
+    if (err)
+        os << errorPageName(err->page_id);
+    else
+        os << "[none]";
+    return os;
+}
+
index 18c3dfa4c6dfae2ede277e9af34a0f7d2f5a5e05..fc37db545f8b0c8a7c9f7d30105983b6d964a96e 100644 (file)
@@ -351,5 +351,7 @@ protected:
  */
 bool strHdrAcptLangGetItem(const String &hdr, char *lang, int langLen, size_t &pos);
 
+std::ostream &operator <<(std::ostream &, const ErrorState *);
+
 #endif /* SQUID_ERRORPAGE_H */
 
index 3c0660d95139c56d054c1f636548f7730e229be0..5561d63030cb99b700d8db80d770ee6533706263 100644 (file)
@@ -19,3 +19,5 @@ void TemplateFile::loadDefault() STUB
 TemplateFile::TemplateFile(char const*, err_type) STUB
 bool TemplateFile::loadFor(const HttpRequest *) STUB_RETVAL(false)
 
+std::ostream &operator <<(std::ostream &os, const ErrorState *) STUB_RETVAL(os)
+