]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
add DNSName::toLogString
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 17 Mar 2016 10:11:40 +0000 (11:11 +0100)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 17 Mar 2016 11:55:43 +0000 (12:55 +0100)
pdns/dnsname.cc
pdns/dnsname.hh

index fece6db044eca1ecdcf1320ce94763ca1499d64b..de30cf67feeb22f4ca3007738229bab4dc3a343b 100644 (file)
@@ -137,6 +137,23 @@ std::string DNSName::toString(const std::string& separator, const bool trailing)
   return ret.substr(0, ret.size()-!trailing);
 }
 
+std::string DNSName::toLogString() const
+{
+  if (empty()) {
+    return "(empty)";
+  }
+
+ if(isRoot())
+    return ".";
+
+  std::string ret;
+  for(const auto& s : getRawLabels()) {
+    ret+= escapeLabel(s) + ".";
+  }
+
+  return ret;
+}
+
 std::string DNSName::toDNSString() const
 {
   if (empty())
index cd9ad2618d26500226df6721af7bcc7657e504a9..a0662cb26a3aa10b64778209b5f147fdc8cb8510 100644 (file)
@@ -52,6 +52,7 @@ public:
   bool operator!=(const DNSName& other) const { return !(*this == other); }
 
   std::string toString(const std::string& separator=".", const bool trailing=true) const;              //!< Our human-friendly, escaped, representation
+  std::string toLogString() const; //!< like plain toString, but returns (empty) on empty names
   std::string toStringNoDot() const { return toString(".", false); }
   std::string toStringRootDot() const { if(isRoot()) return "."; else return toString(".", false); }
   std::string toDNSString() const;           //!< Our representation in DNS native format