void enableDhtLogging(dht::DhtRunner& dht) { dht.setLoggers( [](char const* m, va_list args){ dout << "ERR"; printDhtLog(dout, m, args); }, [](char const* m, va_list args){ dout << "WARN"; printDhtLog(dout, m, args); }, [](char const* m, va_list args){ printDhtLog(dout, m, args); } ); }
void enableFileLogging(dht::DhtRunner &dht, const std::string &path) { auto logfile = std::make_shared<std::fstream>(); logfile->open(path, std::ios::out); dht.setLoggers( [=](char const *m, va_list args) { printLog(*logfile, m, args); }, [=](char const *m, va_list args) { printLog(*logfile, m, args); }, [=](char const *m, va_list args) { printLog(*logfile, m, args); } ); }
void enableLogging(dht::DhtRunner &dht) { dht.setLoggers( [](char const *m, va_list args) { std::cerr << red; printLog(std::cerr, m, args); std::cerr << def; }, [](char const *m, va_list args) { std::cout << yellow; printLog(std::cout, m, args); std::cout << def; }, [](char const *m, va_list args) { printLog(std::cout, m, args); } ); }
void disableLogging(dht::DhtRunner &dht) { dht.setLoggers(dht::NOLOG, dht::NOLOG, dht::NOLOG); }