Daniel Carvalho has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/41395 )

Change subject: base: Add default log functionality to Logger
......................................................................

base: Add default log functionality to Logger

The only difference between the NormalLogger and Logger is
a simple implementation for log(), which is then called by
the other loggers. Since this is common to everybody, move
this implementation to Logger and remove NormalLogger.

This makes it possible to test the NormalLoggers using the
current gtest logging framework.

Change-Id: I6805fa14f58ddc7d37b00fcd7fcacb32e0b5d456
Signed-off-by: Daniel R. Carvalho <oda...@yahoo.com.br>
---
M src/base/logging.cc
M src/base/logging.hh
2 files changed, 7 insertions(+), 15 deletions(-)



diff --git a/src/base/logging.cc b/src/base/logging.cc
index b8f20f9..1290455 100644
--- a/src/base/logging.cc
+++ b/src/base/logging.cc
@@ -46,27 +46,18 @@

 namespace {

-class NormalLogger : public Logger
+class ExitLogger : public Logger
 {
   public:
     using Logger::Logger;

   protected:
-    void log(const Loc &loc, std::string s) override { std::cerr << s; }
-};
-
-class ExitLogger : public NormalLogger
-{
-  public:
-    using NormalLogger::NormalLogger;
-
-  protected:
     void
     log(const Loc &loc, std::string s) override
     {
         std::stringstream ss;
         ccprintf(ss, "Memory Usage: %ld KBytes\n", memUsage());
-        NormalLogger::log(loc, s + ss.str());
+        Logger::log(loc, s + ss.str());
     }
 };

@@ -81,9 +72,9 @@

 ExitLogger panicLogger("panic: ");
 FatalLogger fatalLogger("fatal: ");
-NormalLogger warnLogger("warn: ");
-NormalLogger infoLogger("info: ");
-NormalLogger hackLogger("hack: ");
+Logger warnLogger("warn: ");
+Logger infoLogger("info: ");
+Logger hackLogger("hack: ");

 } // anonymous namespace

diff --git a/src/base/logging.hh b/src/base/logging.hh
index 29a9563..e740e1d 100644
--- a/src/base/logging.hh
+++ b/src/base/logging.hh
@@ -126,7 +126,8 @@
   protected:
     bool enabled;

-    virtual void log(const Loc &loc, std::string s) = 0;
+    /** Generates the log message. By default it is sent to cerr. */
+    virtual void log(const Loc &loc, std::string s) { std::cerr << s; }
     virtual void exit() { /* Fall through to the abort in exit_helper. */ }

     const char *prefix;

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/41395
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I6805fa14f58ddc7d37b00fcd7fcacb32e0b5d456
Gerrit-Change-Number: 41395
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to