From: Charles-Henri Bruyand Date: Fri, 30 Apr 2021 14:58:36 +0000 (+0200) Subject: mark logging methods as const X-Git-Tag: dnsdist-1.7.0-alpha1~122^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd74c405032d9082b9ebcc452667710bee564273;p=thirdparty%2Fpdns.git mark logging methods as const --- diff --git a/pdns/recursordist/logging.cc b/pdns/recursordist/logging.cc index 7b058c4bcc..7d1db97897 100644 --- a/pdns/recursordist/logging.cc +++ b/pdns/recursordist/logging.cc @@ -31,17 +31,17 @@ namespace Logging return shared_from_this(); } - bool Logger::enabled() + bool Logger::enabled() const { return true; } - void Logger::info(const std::string& msg) + void Logger::info(const std::string& msg) const { logMessage(msg, boost::none); } - void Logger::logMessage(const std::string& msg, boost::optional err) + void Logger::logMessage(const std::string& msg, boost::optional err) const { if (_level > _verbosity) { return ; @@ -60,12 +60,12 @@ namespace Logging _callback(entry); } - void Logger::error(int err, const std::string& msg) + void Logger::error(int err, const std::string& msg) const { logMessage(msg, std::string(std::strerror(err))); } - void Logger::error(const std::string& err, const std::string& msg) + void Logger::error(const std::string& err, const std::string& msg) const { logMessage(msg, err); } diff --git a/pdns/recursordist/logging.hh b/pdns/recursordist/logging.hh index 4cc833c43a..58c93dd822 100644 --- a/pdns/recursordist/logging.hh +++ b/pdns/recursordist/logging.hh @@ -69,12 +69,12 @@ namespace Logging { class Logger: public Logr::Logger, public std::enable_shared_from_this { public: - bool enabled() override; - void info(const std::string& msg) override; - void error(int err, const std::string& msg) override; - void error(const std::string& err, const std::string& msg) override; - std::shared_ptr v(size_t level) override; + bool enabled() const override; + void info(const std::string& msg) const override; + void error(int err, const std::string& msg) const override; + void error(const std::string& err, const std::string& msg) const override; + std::shared_ptr v(size_t level) override; std::shared_ptr withValues(const std::string& key, const Logr::Loggable& value) override; virtual std::shared_ptr withName(const std::string& name) override; @@ -89,7 +89,7 @@ namespace Logging { size_t getVerbosity() const; void setVerbosity(size_t verbosity); private: - void logMessage(const std::string& msg, boost::optional err); + void logMessage(const std::string& msg, boost::optional err) const; std::shared_ptr getptr(); std::shared_ptr _parent{nullptr}; diff --git a/pdns/recursordist/logr.hh b/pdns/recursordist/logr.hh index 7a88fc06b3..a592c781d7 100644 --- a/pdns/recursordist/logr.hh +++ b/pdns/recursordist/logr.hh @@ -37,7 +37,7 @@ namespace Logr { // Enabled tests whether this Logger is enabled. For example, commandline // flags might be used to set the logging verbosity and disable some info // logs. - virtual bool enabled() = 0; + virtual bool enabled() const = 0; // Info logs a non-error message with the given key/value pairs as context. // @@ -45,7 +45,7 @@ namespace Logr { // the log line. The key/value pairs can then be used to add additional // variable information. The key/value pairs should alternate string // keys and arbitrary values. - virtual void info(const std::string& msg) = 0; + virtual void info(const std::string& msg) const = 0; // Error logs an error, with the given message and key/value pairs as context. // It functions similarly to calling Info with the "error" named value, but may @@ -55,8 +55,8 @@ namespace Logr { // The msg field should be used to add context to any underlying error, // while the err field should be used to attach the actual error that // triggered this log line, if present. - virtual void error(const std::string& err, const std::string& msg) = 0; - virtual void error(int err, const std::string& msg) = 0; + virtual void error(const std::string& err, const std::string& msg) const = 0; + virtual void error(int err, const std::string& msg) const = 0; // V returns an Logger value for a specific verbosity level, relative to // this Logger. In other words, V values are additive. V higher verbosity