58 ERROR: ALE missing ...
59 Shutdown: Digest authentication.
60 Shutdown: Negotiate authentication.
-62 ERROR: ... while accepting a TLS connection on ...: ...
+62 ERROR: Cannot accept a TLS connection ...problem: ...
63 Resuming indexing cache_dir # ... from ...
64 DNS IPv4 socket created at ..., FD ...
65 WARNING: Indexer ignores a cache_dir entry: ...
return os;
}
+/// Helps prints T object using object's T::printWithExtras() method.
+template <class T>
+class WithExtras
+{
+public:
+ /// caller must ensure `t` lifetime extends to the last use of this class instance
+ explicit WithExtras(const T &t): toPrint(t) {}
+ const T &toPrint;
+};
+
+/// writes T object to the given stream using object's T::printWithExtras() method
+template <class T>
+inline auto &
+operator <<(std::ostream &os, const WithExtras<T> &a) {
+ a.toPrint.printWithExtras(os);
+ return os;
+}
+
#endif /* SQUID_SRC_BASE_IOMANIP_H */
return;
case Security::IoResult::ioError:
- debugs(83, (handshakeResult.important ? Important(62) : 2), "ERROR: " << handshakeResult.errorDescription <<
- " while accepting a TLS connection on " << conn->clientConnection << ": " << handshakeResult.errorDetail);
+ debugs(83, (handshakeResult.important ? Important(62) : 2), "ERROR: Cannot accept a TLS connection" <<
+ Debug::Extra << "problem: " << WithExtras(handshakeResult));
// TODO: No ConnStateData::tunnelOnError() on this forward-proxy code
// path because we cannot know the intended connection target?
conn->updateError(ERR_SECURE_ACCEPT_FAIL, handshakeResult.errorDetail);
}
case Security::IoResult::ioError:
- debugs(83, (handshakeResult.important ? DBG_IMPORTANT : 2), "ERROR: " << handshakeResult.errorDescription <<
- " while SslBump-accepting a TLS connection on " << clientConnection << ": " << handshakeResult.errorDetail);
+ debugs(83, (handshakeResult.important ? DBG_IMPORTANT : 2), "ERROR: Cannot SslBump-accept a TLS connection" <<
+ Debug::Extra << "problem: " << WithExtras(handshakeResult));
updateError(errCategory = ERR_SECURE_ACCEPT_FAIL, handshakeResult.errorDetail);
break;
} // namespace Security
+/// common part of printGist() and printWithExtras()
void
-Security::IoResult::print(std::ostream &os) const
+Security::IoResult::printDescription(std::ostream &os) const
{
- const char *strCat = "unknown";
+ const char *strCat = nullptr;
switch (category) {
case ioSuccess:
strCat = "success";
strCat = "want-write";
break;
case ioError:
- strCat = "error";
+ strCat = errorDescription;
break;
}
- os << strCat;
-
- if (errorDescription)
- os << ", " << errorDescription;
+ os << (strCat ? strCat : "unknown");
+}
+void
+Security::IoResult::printGist(std::ostream &os) const
+{
+ printDescription(os);
if (important)
os << ", important";
+ // no errorDetail in this summary output
+}
+
+void
+Security::IoResult::printWithExtras(std::ostream &os) const
+{
+ printDescription(os);
+ if (errorDetail)
+ os << Debug::Extra << "error detail: " << errorDetail;
+ // this->important flag may affect caller debugs() level, but the flag
+ // itself is not reported to the admin explicitly
}
// TODO: Replace high-level ERR_get_error() calls with ForgetErrors() calls or
/// convenience wrapper to detect whether more I/O is needed
bool wantsIo() const { return category == ioWantRead || category == ioWantWrite; }
- void print(std::ostream &os) const;
+ /// reports brief summary (on one line) suitable for low-level debugging
+ void printGist(std::ostream &) const;
+
+ /// reports detailed summary, often using multiple Debug::Extra lines
+ /// suitable for level-0/1 cache.log messages
+ void printWithExtras(std::ostream &) const;
ErrorDetailPointer errorDetail; ///< ioError case details (or nil)
/* the data members below facilitate human-friendly debugging */
const char *errorDescription = nullptr; ///< a brief description of an error
bool important = false; ///< whether the error was serious/unusual
+
+private:
+ void printDescription(std::ostream &) const;
};
inline std::ostream &
operator <<(std::ostream &os, const IoResult &result)
{
- result.print(os);
+ result.printGist(os);
return os;
}
}
// TODO: Honor result.important when working in a reverse proxy role?
- debugs(83, 2, "ERROR: Cannot establish a TLS connection to " << serverConnection() << ':' <<
- Debug::Extra << "problem: " << result.errorDescription <<
- RawPointer("detail: ", result.errorDetail).asExtra());
+ debugs(83, 2, "ERROR: Cannot establish a TLS connection" <<
+ Debug::Extra << "problem: " << WithExtras(result) <<
+ Debug::Extra << "connection: " << serverConnection());
recordNegotiationDetails();
noteNegotiationError(result.errorDetail);
}
#include "security/Io.h"
Security::IoResult Security::Accept(Comm::Connection &) STUB_RETVAL(IoResult(IoResult::ioError))
Security::IoResult Security::Connect(Comm::Connection &) STUB_RETVAL(IoResult(IoResult::ioError))
+void Security::IoResult::printGist(std::ostream &) const STUB
+void Security::IoResult::printWithExtras(std::ostream &) const STUB
void Security::ForgetErrors() STUB
#include "security/KeyData.h"