From 86f18f26fc7223cc8a63a792d2be1267f573f97c Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 30 Nov 2017 16:17:06 -0800 Subject: [PATCH] misc: Move the ExitLogger class definition into misc.cc 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 Maintainer: Gabe Black --- src/base/misc.cc | 38 +++++++++++++++++++++++--------------- src/base/misc.hh | 9 --------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/base/misc.cc b/src/base/misc.cc index 2392d51fd..be97368f3 100644 --- a/src/base/misc.cc +++ b/src/base/misc.cc @@ -51,21 +51,6 @@ #include "base/types.hh" #include "sim/core.hh" - -Logger & -Logger::get(LogLevel ll) -{ - static std::array 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 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]; +} diff --git a/src/base/misc.hh b/src/base/misc.hh index a731c7607..7b0d46274 100644 --- a/src/base/misc.hh +++ b/src/base/misc.hh @@ -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__); \ -- 2.30.2