::arg().laxParse(argc, argv); // do a lax parse
if (::arg().mustDo("version")) {
- showProductVersion();
- showBuildConfiguration();
+ cout << getProductVersion();
+ cout << getBuildConfiguration();
return 0;
}
DLOG(g_log << Logger::Warning << "Verbose logging in effect" << endl);
- showProductVersion();
+ for (const string& line : getProductVersionLines()) {
+ g_log << Logger::Info << line << endl;
+ }
try {
mainthread();
::arg().laxParse(argc, argv); // do a lax parse
if (::arg().mustDo("version")) {
- showProductVersion();
- showBuildConfiguration();
+ cout << getProductVersion();
+ cout << getBuildConfiguration();
return 0;
}
if (::arg().mustDo("help")) {
}
g_log.setLoglevel(s_logUrgency);
g_log.toConsole(s_logUrgency);
- showProductVersion();
+
+ for (const string& line : getProductVersionLines()) {
+ g_log << Logger::Info << line << endl;
+ }
if (!::arg().mustDo("structured-logging")) {
g_log << Logger::Error << "Disabling structured logging is not supported anymore" << endl;
}
*/
#include "config.h"
-
-#include "logger.hh"
#include "version.hh"
+#include "namespaces.hh"
+
+#ifdef PDNS_MODULES
#include "dnsbackend.hh"
+#endif
+#include <sstream>
#include <boost/algorithm/string/join.hpp>
static ProductType productType;
return "unknown";
}
-void showProductVersion()
+vector<string> getProductVersionLines()
{
- g_log << Logger::Warning << productName() << " " << VERSION << " (C) "
+ vector<string> ret;
+ std::istringstream istr(getProductVersion());
+ for (string line; std::getline(istr, line);) {
+ ret.emplace_back(line);
+ }
+ return ret;
+}
+
+string getProductVersion()
+{
+ ostringstream ret;
+ ret << productName() << " " << VERSION << " (C) "
"PowerDNS.COM BV"
<< endl;
- g_log << Logger::Warning << "Using " << (sizeof(unsigned long) * 8) << "-bits mode. "
+ ret << "Using " << (sizeof(unsigned long) * 8) << "-bits mode. "
"Built using "
<< compilerVersion()
#ifndef REPRODUCIBLE
<< " on " __DATE__ " " __TIME__ " by " BUILD_HOST
#endif
<< "." << endl;
- g_log << Logger::Warning << "PowerDNS comes with ABSOLUTELY NO WARRANTY. "
+ ret << "PowerDNS comes with ABSOLUTELY NO WARRANTY. "
"This is free software, and you are welcome to redistribute it "
"according to the terms of the GPL version 2."
<< endl;
+ return ret.str();
}
-void showBuildConfiguration()
+string getBuildConfiguration()
{
- g_log << Logger::Warning << "Features: "
+ ostringstream ret;
+ ret << "Features: "
<<
#ifdef HAVE_LIBDECAF
"decaf "
endl;
#ifdef PDNS_MODULES
// Auth only
- g_log << Logger::Warning << "Built-in modules: " << PDNS_MODULES << endl;
+ ret << "Built-in modules: " << PDNS_MODULES << endl;
const auto& modules = BackendMakers().getModules();
- g_log << Logger::Warning << "Loaded modules: " << boost::join(modules, " ") << endl;
+ ret << "Loaded modules: " << boost::join(modules, " ") << endl;
#endif
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
#ifdef PDNS_CONFIG_ARGS
#define double_escape(s) #s
#define escape_quotes(s) double_escape(s)
// NOLINTEND(cppcoreguidelines-macro-usage)
- g_log << Logger::Warning << "Configured with: " << escape_quotes(PDNS_CONFIG_ARGS) << endl;
+ ret << "Configured with: " << escape_quotes(PDNS_CONFIG_ARGS) << endl;
#undef escape_quotes
#undef double_escape
#endif
+ return ret.str();
}
string fullVersionString()
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#pragma once
-#include <string>
+#include "namespaces.hh"
enum ProductType
{
ProductRecursor
};
-std::string compilerVersion();
-void showProductVersion();
-void showBuildConfiguration();
-std::string fullVersionString();
-std::string getPDNSVersion();
-std::string productName();
-std::string productTypeApiType();
+[[nodiscard]] std::string compilerVersion();
+[[nodiscard]] std::vector<std::string> getProductVersionLines();
+[[nodiscard]] std::string getProductVersion();
+[[nodiscard]] std::string getBuildConfiguration();
+[[nodiscard]] std::string fullVersionString();
+[[nodiscard]] std::string getPDNSVersion();
+[[nodiscard]] std::string productName();
+[[nodiscard]] std::string productTypeApiType();
void versionSetProduct(ProductType productType_);
-ProductType versionGetProduct();
+[[nodiscard]] ProductType versionGetProduct();