Refactor and rename ConsoleObserver...
...Renamed to "ILogger", to designate that this is an Interface for a Logger. This "Interface" is pure virtual, so that it cannot be instantiated directly. This makes it clear that it is intended to be derived. Finally, got rid of all the individual log-style methods and replaced with SendLog. The idea here is that day-to-day users will only interact with ILogger through ConsoleSingleton (or, likely, LoggerSingleton in the future). This singleton will manage an arbirtary collection of ILogger, and call SendLog with the appropriate parameters based on what the user requests. Therefore, the singleton itself will have the individual Log, Message, Error, etc... methods, while stil allowing us to simplify the code base of ILogger and its derived classes.
This commit is contained in:
@@ -667,7 +667,7 @@ CmdTestConsoleOutput::CmdTestConsoleOutput()
|
||||
}
|
||||
|
||||
namespace Gui {
|
||||
class TestConsoleObserver : public Base::ConsoleObserver
|
||||
class TestConsoleObserver : public Base::ILogger
|
||||
{
|
||||
QMutex mutex;
|
||||
public:
|
||||
@@ -675,25 +675,24 @@ public:
|
||||
TestConsoleObserver() : matchMsg(0), matchWrn(0), matchErr(0), matchLog(0)
|
||||
{
|
||||
}
|
||||
virtual void Warning(const char * msg)
|
||||
{
|
||||
void SendLog(const std::string& msg, Base::LogStyle level){
|
||||
|
||||
QMutexLocker ml(&mutex);
|
||||
matchWrn += strcmp(msg, "Write a warning to the console output.\n");
|
||||
}
|
||||
virtual void Message(const char * msg)
|
||||
{
|
||||
QMutexLocker ml(&mutex);
|
||||
matchMsg += strcmp(msg, "Write a message to the console output.\n");
|
||||
}
|
||||
virtual void Error(const char * msg)
|
||||
{
|
||||
QMutexLocker ml(&mutex);
|
||||
matchErr += strcmp(msg, "Write an error to the console output.\n");
|
||||
}
|
||||
virtual void Log(const char * msg)
|
||||
{
|
||||
QMutexLocker ml(&mutex);
|
||||
matchLog += strcmp(msg, "Write a log to the console output.\n");
|
||||
|
||||
switch(level){
|
||||
case Base::LogStyle::Warning:
|
||||
matchWrn += strcmp(msg.c_str(), "Write a warning to the console output.\n");
|
||||
break;
|
||||
case Base::LogStyle::Message:
|
||||
matchMsg += strcmp(msg.c_str(), "Write a message to the console output.\n");
|
||||
break;
|
||||
case Base::LogStyle::Error:
|
||||
matchErr += strcmp(msg.c_str(), "Write an error to the console output.\n");
|
||||
break;
|
||||
case Base::LogStyle::Log:
|
||||
matchLog += strcmp(msg.c_str(), "Write a log to the console output.\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user