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

Change subject: base: Fix incorrect use of Logger::print
......................................................................

base: Fix incorrect use of Logger::print

Previously when a formatted message was printed in a
Logger it would use the wrong function, and thus skip
the warning triggered by ccprintf. Fix this by merging
two prints to avoid ambiguity.

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



diff --git a/src/base/logging.hh b/src/base/logging.hh
index e740e1d..4ef700a 100644
--- a/src/base/logging.hh
+++ b/src/base/logging.hh
@@ -90,24 +90,20 @@

     virtual ~Logger() {};

-    void
-    print(const Loc &loc, const std::string &str)
-    {
-        std::stringstream ss;
-        ss << prefix << str;
-        if (str.length() && str.back() != '\n' && str.back() != '\r')
-            ss << std::endl;
-        if (!enabled)
-            return;
-        log(loc, ss.str());
-    }
-
     template<typename ...Args> void
     print(const Loc &loc, const char *format, const Args &...args)
     {
         std::stringstream ss;
         ccprintf(ss, format, args...);
-        print(loc, ss.str());
+        const std::string str = ss.str();
+
+        std::stringstream ss_formatted;
+        ss_formatted << prefix << str;
+        if (str.length() && str.back() != '\n' && str.back() != '\r')
+            ss_formatted << std::endl;
+        if (!enabled)
+            return;
+        log(loc, ss_formatted.str());
     }

     template<typename ...Args> void
diff --git a/src/base/logging.test.cc b/src/base/logging.test.cc
index 3075ab7..c979148 100644
--- a/src/base/logging.test.cc
+++ b/src/base/logging.test.cc
@@ -141,7 +141,7 @@
  * Test the variadic-arg print for strings with arguments missing using
  * TestLogger.
  */
-TEST(LoggingTest, DISABLED_TestLoggerVariadicStringMissingPrint)
+TEST(LoggingTest, TestLoggerVariadicStringMissingPrint)
 {
     TestLogger logger("test: ");


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/41399
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: Idc51d2ef28ab4721d2be16f3e5fce19c494a0d47
Gerrit-Change-Number: 41399
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