misc: Move the ExitLogger class definition into misc.cc
authorGabe Black <gabeblack@google.com>
Fri, 1 Dec 2017 00:17:06 +0000 (16:17 -0800)
committerGabe Black <gabeblack@google.com>
Mon, 4 Dec 2017 23:10:29 +0000 (23:10 +0000)
This class isn't referred to outside of misc.hh, and isn't necessarily
useful outside of the particular logging setup implemented in misc.cc.
The Logger class itself is different since it provides a generic
interface that can be used with different logging schemes.

Change-Id: Ibae926fea039d9e3d75a43d97348bc4a3c5d555e
Reviewed-on: https://gem5-review.googlesource.com/6225
Reviewed-by: Brandon Potter <Brandon.Potter@amd.com>
Maintainer: Gabe Black <gabeblack@google.com>

src/base/misc.cc
src/base/misc.hh

index 2392d51fdd60670a51e70f5b4097134c57d5d7f1..be97368f30e7240c63197c24b807c9b140791f49 100644 (file)
 #include "base/types.hh"
 #include "sim/core.hh"
 
-
-Logger &
-Logger::get(LogLevel ll)
-{
-    static std::array<Logger *, NUM_LOG_LEVELS> loggers{{
-        new ExitLogger(std::cerr, "panic"),
-        new ExitLogger(std::cerr, "fatal"),
-        new Logger(std::cerr, "warn"),
-        new Logger(std::cerr, "info"),
-        new Logger(std::cerr, "hack"),
-    }};
-
-    return *loggers[ll];
-}
-
 void
 Logger::setLevel(LogLevel ll)
 {
@@ -104,6 +89,15 @@ Logger::printEpilogue(const char *func, const char *file, int line,
     }
 }
 
+class ExitLogger : public Logger
+{
+  public:
+    using Logger::Logger;
+
+    void printEpilogue(const char *func, const char *file, int line,
+                       const char *format) override;
+};
+
 void
 ExitLogger::printEpilogue(const char *func, const char *file, int line,
                             const char *format)
@@ -112,3 +106,17 @@ ExitLogger::printEpilogue(const char *func, const char *file, int line,
 
     ccprintf(stream, "Memory Usage: %ld KBytes\n", memUsage());
 }
+
+Logger &
+Logger::get(LogLevel ll)
+{
+    static std::array<Logger *, NUM_LOG_LEVELS> loggers{{
+        new ExitLogger(std::cerr, "panic"),
+        new ExitLogger(std::cerr, "fatal"),
+        new Logger(std::cerr, "warn"),
+        new Logger(std::cerr, "info"),
+        new Logger(std::cerr, "hack"),
+    }};
+
+    return *loggers[ll];
+}
index a731c76078804b22057c0e39ede16c81a1bbe1db..7b0d4627401817edb4119798aa00c1c9fcc9a042 100644 (file)
@@ -125,15 +125,6 @@ class Logger
     const char *prefix;
 };
 
-class ExitLogger : public Logger
-{
-  public:
-    using Logger::Logger;
-
-    void printEpilogue(const char *func, const char *file, int line,
-                       const char *format) override;
-};
-
 #define exit_message(logger, code, ...)                                 \
     do {                                                                \
         logger.print(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__);    \