}
};
template <>
-std::string Loggable<DNSName>::to_string() const;
-template <>
-std::string Loggable<ComboAddress>::to_string() const;
-template <>
-std::string Loggable<std::string>::to_string() const;
+inline std::string Loggable<DNSName>::to_string() const
+{
+ return _t.toLogString();
+}
template <>
-std::string Loggable<std::vector<std::string>>::to_string() const;
+inline std::string Loggable<ComboAddress>::to_string() const
+{
+ return _t.toLogString();
+}
template <>
-std::string Loggable<std::set<int>>::to_string() const;
+inline std::string Loggable<std::string>::to_string() const
+{
+ return _t;
+}
-// Loggable<std::string>::Loggable(const std::string& v): _t(v) {}
+template <typename T>
+struct IterLoggable : public Logr::Loggable
+{
+ const T& _t1;
+ const T& _t2;
+ IterLoggable(const T& v1, const T& v2) :
+ _t1(v1), _t2(v2)
+ {
+ }
+ std::string to_string() const
+ {
+ std::ostringstream oss;
+ bool first = true;
+ for (auto i = _t1; i != _t2; i++) {
+ if (!first) {
+ oss << ' ';
+ }
+ else {
+ first = false;
+ }
+ oss << *i;
+ }
+ return oss.str();
+ }
+};
typedef void (*EntryLogger)(const Entry&);
return res;
}
-template struct Loggable<DNSName>;
-template struct Loggable<ComboAddress>;
-template struct Loggable<std::string>;
-template struct Loggable<size_t>;
-
-template <>
-std::string Loggable<DNSName>::to_string() const
-{
- return _t.toLogString();
-}
-template <>
-std::string Loggable<ComboAddress>::to_string() const
-{
- return _t.toLogString();
-}
-template <>
-std::string Loggable<std::string>::to_string() const
-{
- return _t;
-}
-template <>
-std::string Loggable<std::vector<std::string>>::to_string() const
-{
- std::ostringstream oss;
- bool first = true;
- for (const auto& e : _t) {
- if (!first) {
- oss << ' ';
- }
- else {
- first = false;
- }
- oss << e;
- }
- return oss.str();
-}
-
-template <>
-std::string Loggable<std::set<int>>::to_string() const
-{
- std::ostringstream oss;
- bool first = true;
- for (const auto& e : _t) {
- if (!first) {
- oss << ' ';
- }
- else {
- first = false;
- }
- oss << e;
- }
- return oss.str();
-}
-
std::shared_ptr<Logr::Logger> Logger::withName(const std::string& name) const
{
std::shared_ptr<Logger> res;
g_log << Logger::Info << endl;
}
else {
- log->info(Logr::Info, "CPU affinity has been set", "thread", Logging::Loggable(n), "cpumap", Logging::Loggable(cpuMapping->second));
+ log->info(Logr::Info, "CPU affinity has been set", "thread", Logging::Loggable(n), "cpumap", Logging::IterLoggable(cpuMapping->second.begin(), cpuMapping->second.end()));
}
}
else {
g_log << Logger::Info << ' ' << strerror(rc) << endl;
}
else {
- log->info(Logr::Warning, "Error setting CPU affinity", "thread", Logging::Loggable(n), "cpumap", Logging::Loggable(cpuMapping->second));
+ log->error(Logr::Warning, rc, "Error setting CPU affinity", "thread", Logging::Loggable(n), "cpumap", Logging::IterLoggable(cpuMapping->second.begin(), cpuMapping->second.end()));
}
}
}
g_log << Logger::Info << endl;
}
else {
- log->info(Logr::Info, "Setting access control", "acl", Logging::Loggable(aclSetting), "addresses", Logging::Loggable(ips));
+ log->info(Logr::Info, "Setting access control", "acl", Logging::Loggable(aclSetting), "addresses", Logging::IterLoggable(ips.begin(), ips.end()));
}
}
g_log << Logger::Warning << endl;
}
else {
- log->info(Logr::Notice, "Will not send queries to", "addresses", Logging::Loggable(ips));
+ log->info(Logr::Notice, "Will not send queries to", "addresses", Logging::IterLoggable(ips.begin(), ips.end()));
}
}
g_log << endl;
}
else {
- log->info(Logr::Info, "Redirecting queries", "zone", Logging::Loggable(zone), "recursion", Logging::Loggable(ad.d_rdForward), "addresses", Logging::Loggable(addresses));
+ log->info(Logr::Info, "Redirecting queries", "zone", Logging::Loggable(zone), "recursion", Logging::Loggable(ad.d_rdForward), "addresses", Logging::IterLoggable(addresses.begin(), addresses.end()));
}
}
}
ifstream ifs(fname.c_str());
if (!ifs) {
SLOG(g_log << Logger::Warning << "Could not open " << fname << " for reading" << endl,
- log->error(Logr::Warning, "Could not open file for reading", "file", Logging::Loggable(fname)));
+ log->error(Logr::Warning, "Could not open file for reading", "file", Logging::Loggable(fname)));
}
else {
string searchSuffix = ::arg()["export-etc-hosts-search-suffix"];