Daniel Carvalho has submitted this change. (
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 <[email protected]>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/41395
Tested-by: kokoro <[email protected]>
Reviewed-by: Giacomo Travaglini <[email protected]>
Maintainer: Bobby R. Bruce <[email protected]>
---
M src/base/logging.cc
M src/base/logging.hh
2 files changed, 7 insertions(+), 15 deletions(-)
Approvals:
Giacomo Travaglini: Looks good to me, approved
Bobby R. Bruce: Looks good to me, approved
kokoro: Regressions pass
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 87bca8e..4ef700a 100644
--- a/src/base/logging.hh
+++ b/src/base/logging.hh
@@ -122,7 +122,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;
4 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the
submitted one.
--
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: 6
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s