]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
mark logging methods as const
authorCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Fri, 30 Apr 2021 14:58:36 +0000 (16:58 +0200)
committerCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Fri, 30 Apr 2021 14:58:36 +0000 (16:58 +0200)
pdns/recursordist/logging.cc
pdns/recursordist/logging.hh
pdns/recursordist/logr.hh

index 7b058c4bcc54c3c31bb5d2612f894e7665d8987a..7d1db97897ae2ce296224a7ea1333ca0eb37c7a6 100644 (file)
@@ -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<const std::string> err)
+  void Logger::logMessage(const std::string& msg, boost::optional<const std::string> 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);
   }
index 4cc833c43a08ace793bddf53e4a8523cdc8f90d1..58c93dd82220feb25c06a1f195ff4309dca91e2e 100644 (file)
@@ -69,12 +69,12 @@ namespace Logging {
   class Logger: public Logr::Logger, public std::enable_shared_from_this<Logger>
   {
   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<Logr::Logger> 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<Logr::Logger> v(size_t level) override;
     std::shared_ptr<Logr::Logger> withValues(const std::string& key, const Logr::Loggable& value) override;
     virtual std::shared_ptr<Logr::Logger> 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<const std::string> err);
+    void logMessage(const std::string& msg, boost::optional<const std::string> err) const;
     std::shared_ptr<Logger> getptr();
 
     std::shared_ptr<Logger> _parent{nullptr};
index 7a88fc06b37aa2b3b0e01123a8cad3723b7c59c6..a592c781d70bcedbdc58115e35a95981f48e9dca 100644 (file)
@@ -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